a work on process

Dynamically Switching To FCKEditor

You are reading a post by James Stewart entitled Dynamically Switching To FCKEditor. It was posted on 22 February 2005 at 3:15 pm.

You can find more posts by returning to the index.

Filed under: Notes
Tagged: , ,

I’m doing a little work building a page editing tool for a CMS. Each page can have a number of different types of elements and I’ve decided that blocks of text will be controlled using FCKEditor. Rather than having a number of FCKEditor instances on a page I wanted to allow the user to be able to click on a button to instantiate an FCKEditor instance and move the text into it. After a little thought, it turned out to just require a pretty simply bit of javascript:

	function switchElement(div_id, text_area_name) {
		var our_div = document.getElementById(div_id);
		thetext = our_div.firstChild;
		var textarea = document.createElement('textarea');
		textarea.setAttribute("id", text_area_name);
		textarea.setAttribute("name", text_area_name);
		textarea.appendChild(thetext);
		our_div.appendChild(textarea);
		var oFCKeditor = new FCKeditor(text_area_name);
		oFCKeditor.BasePath	= '' ;
		oFCKeditor.ReplaceTextarea();
	}

This will convert a block of text contained within a ‘div’ element with a given ID to be converted into an FCKEditor instance. It’ll be pretty trivial to develop this to create the whole form. The next step will be to use XMLHTTPRequest to allow the editing to take place inline.

In the process I noticed that the FCKEditor manual implies that when instantiating the FCKEditor object with:

var oFCKeditor = new FCKeditor(text_area_name);

the user should specify the textarea’s id attribute, but in fact it requires the element’s name attribute.

NB: Only tested in Firefox.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Posts

 

10 Comments »

  • bonsoir,

    je vous remercie de me transmettre le fichier “test” décrit ci-dessus.
    salutations - Jean-Marie Griess

    Comment by Jean-Marie Griess — 11 March 2005 @ 6:05 pm

  • I did the almost the same, but in the Final Candidate preview release the second time you generate a new editor, it fails…

    Comment by Daantje — 17 March 2005 @ 9:48 am

  • Yeah, I had a problem when I switched from RC2 to RC3. A few of us have commented on that on the dicussion boards, but if it’s still there in another RC a bug should definitely be filed.

    Comment by james — 17 March 2005 @ 9:52 am

  • Ah yes. It’s been filed as a bug report:

    https://sourceforge.net/tracker/index.php?func=detail&aid=1158121&group_id=75348&atid=543653

    Comment by james — 17 March 2005 @ 10:21 am

  • Have you had any succes with making FCKeditor work with XMLHTTPRequest to allow inline editing? I really need it for an app I am working on, and have had no luck finding help on this.

    Comment by Tommy — 9 February 2006 @ 1:24 pm

  • I did get it working, but it’s been quite a while since I looked at it as I’m no longer on that project.

    For other work, I’ve abandoned FCKEditor as it was way too bloated and very ugly inside. I’ve done a little work with the wysiwyg editor in Dojo which doesn’t have all the features, but is much lighter and easily integrated with an Ajax application using dojo’s own implementation.

    Comment by James Stewart — 9 February 2006 @ 2:01 pm

  • Hmm. not using Dojo, but I could use some assistance. I built an app to display course syllabi online. (I work for a college) I was using FCKeditor and the app was originally written for ASP, then converted to .NET. Now I am making another conversion to PHP to go along with our CMS (PhpWebsite).

    So i want a page that displays the syllabus, then each editable field that requires use of a wysiwyg editor pass the updates via XMLHTTPRequest to allow for “inline editing”. I really don’t have a preference on which editor I use, but like FCK’s image handler.

    Any help you could give would be greatly appreciated.

    Comment by Tommy — 10 February 2006 @ 10:33 am

  • I’m afraid I’m not in the business of using this comments are as a training/support space! What you’re looking to do should be fairly straightforward, but if you need help I’d suggest signing up for one of the relevant mailing lists or checking to see if there are IRC channels for the tools you’re using.

    Comment by James Stewart — 10 February 2006 @ 10:42 am

  • Well, it was worth a shot I suppose. thanks anyway.

    Comment by Tommy — 10 February 2006 @ 11:03 am

  • Tommy, my company works with editors including this one. We design CF and PHP CMS enabled back ends for business and schools.
    If you would like to out source this we might be interested in the work.

    -Daniel at dosolutions dot com

    Comment by Daniel Hoviss — 10 March 2006 @ 8:37 am

TrackBack URI

Leave a comment

Login Method

OpenID

Anonymous