Hi all i have an CKeditor in my screen ckeditor is displaying but when i try to get the instance of the editor i have the value null or undefined how can i get the ckeditor instance can any one help me here
function editor() { //i have null here for (name in CKEDITOR.instances) { CKEDITOR.instances[name].destroy() } var editor = CKEDITOR.instances.editor1;//i have null here editor.on('key', function () { var data = editor.getData(); }); } $(document).ready(function () { var editorShort = CKEDITOR.editor.replace('popup_editor1'); editor(); });
It could be that the instances variable is simply undefined at that time. Depending on what you really want to do with the editor, I suggest that you do the on key bindings and other such things inside instanceReady, which is a CKEditor event.
$(document).ready(function () { // You can define it before replacing the editor CKEDITOR.on('instanceReady', function(evt){ // Do your bindings and other actions here for example // You can access each editor that this event has fired on from the event var editor = evt.editor; }); // replace editor var editorShort = CKEDITOR.editor.replace('popup_editor1'); });
See the documentation at http://docs.ckeditor.com/#!/api/CKEDITOR-event-instanceReady