CKeditor instance is null or undefined?

匿名 (未验证) 提交于 2019-12-03 01:41:02

问题:

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();  });

回答1:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!