Hi all,
if I do :
CKEditor loads into a textarea with the id page_content. Then if I do :
I can close the editor with an input button like this :
But how do I do the same thing using :
instead of :
please?
How do I "Fish" For the instance so that I can close it using destroy in a function???
'page_content' is an id and not a class.
Does not work, so I guess ckeditor lacks any core logic for instances if replaceClass is used???
Nothing in the api helps.
Does anyone have any clue?
Thanks,
Zanpakutō
if I do :
editor = CKEDITOR.replace('page_content');
var oEditor = CKEDITOR.instances.page_content;CKEditor loads into a textarea with the id page_content. Then if I do :
function ExecuteClose() {
alert(oEditor.name);
oEditor.destroy();
}I can close the editor with an input button like this :
<input onclick="ExecuteClose();" type="button" value="Execute Close" />
But how do I do the same thing using :
editor = CKEDITOR.replaceClass = 'cktextarea';
instead of :
editor = CKEDITOR.replace('page_content');please?
How do I "Fish" For the instance so that I can close it using destroy in a function???
'page_content' is an id and not a class.
var oEditor = CKEDITOR.instances.cktextarea;
Does not work, so I guess ckeditor lacks any core logic for instances if replaceClass is used???
Nothing in the api helps.
Does anyone have any clue?
Thanks,
Zanpakutō

Re: obtaining instance when using replaceClass?
The javascript :
function initCke() { if ( editor ) return; CKEDITOR.plugins.addExternal('blablabla', 'somepath/somedir/'); CKEDITOR.config.customConfig = '../ckeditor-custom-config.js'; editor = CKEDITOR.replaceClass = 'ck-textarea'; }; function CloseEditor(i) { var oEditor = CKEDITOR.instances[i]; oEditor.destroy(); editor = null; }; initCke();The html markup :
<input onclick="CloseEditor('textarea-id');" type="button" value="Close Editor" /> <textarea name="this-textarea" id="textarea-id" cols="50" class="ck-textarea" rows="10"> </textarea>Each instance created by setting replaceClass which is just a variable and not a function, can be referenced by the id of the same element. So applying the function to each specific instance each button is next to is the right thing to do; if there is more than one editor on a single page. You simply need to make sure that the each textarea tag has a unique id and that the same id string is added as input to the CloseEditor() function call in the input button's onclick action.
Just posting this in case anyone wants a shortcut.
Thanks,
Zanpakutō