Hello everyone.
I had a big problem when moved to CKEditor from FCKeditor because of dynamic loading.
Background:
FCKeditor had a beautiful function called createHTML that took care of everything as it should. With CKeditor things had changed.. when you echo $instante->editor(...) you get javascript code that should be executed by browser.. so far, everything is fine.
Now imagine the situation.. you have a javascript window manager implemented where every window that you open gets it's contents via AJAX (html code that is being put to the div via .innerHTML). Some of my windows were supposed to get CKEditor code and insert it to a div in real time (no page refresh of course) which created a problem.. JS code generated by CKEditor (CKEDITOR.replace and etc...) wasn't executed due to ajax design. I was getting <textarea> tag in place with useless javascript code (useless because not executed) and that was it. AJAX example that is included in CKEditor wasn't a solution due to complex implementation.
The "hack":
CKEditor generates the following code:
<textarea ...>contents</textarea>
Javascript telling what basepath is
Javascript loading ckeditor.js
Javascript calling CKEDITOR.replace(....)
So you need to get some this JS executed, but how?
Well... in PHP you parse the code:
<textarea> tag is beeig put the the correct div
basepath and ckeditor.js are not needed every time you load a new ckeditor so include them manually in <head> of your page.
CKEDITOR.replace.. well you need to execute it to get a working editor and not a blank textarea.
Here is how i did it:
http://wadsoftware.com/ck/index.php
http://wadsoftware.com/ck/index.phps
I know my explanation is a bit confusing but I hope it helps someone.
Wed, 02/03/2010 - 18:17
#1