CKEditor inline instance fails to reload after it's destroyed

江枫思渺然 提交于 2019-12-13 02:33:10

问题


For the app I'm working on, users can edit text inline using CKEditor. Recently, I've included 2 extra plugins that I modified: stylescombo and bidi. For both of these, I just gave it a new name and modified what happens when text is clicked.

When a user clicks on a block of text to edit, I would dynamically load CKEditor onto it like this:

HTML: <div id="text-content">sample text</div>

JS: var $text = $("#text-content");
    $text.attr("contenteditable", true);
    CKEDITOR.disableAutoInline = true;
    ...
    // toolbarOptions is an array of toolbar options
    var editor = CKEDITOR.inline("text-content", {toolbar: toolbarOptions});

When user clicks away from the CKEditor, I would destroy the editor like this:

editor.destroy(true);
editor = null;
$("#text-content").removeAttr("contenteditable");

Now all of this works fine the first time, but when I attempt to edit the text-content again, the CKEditor fails to load without any error whatsoever. I console log the "editor" variable and I see the status of the editor being "unloaded". After some debugging, I found that if I don't load one of the 2 customized plugins above, the editor can reload after being destroyed. Any ideas why those 2 plugins are affecting the reloading of the inline CKEditor?

Demo: http://jsfiddle.net/22A6F/

来源:https://stackoverflow.com/questions/23896892/ckeditor-inline-instance-fails-to-reload-after-its-destroyed

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