Turning CKEditor 4 inline editing on and off with JavaScript

自作多情 提交于 2019-12-04 12:14:30

问题


I need to be able to toggle inline editing on/off with a button. See here for example of inline editing: http://nightly-v4.ckeditor.com/3559/samples/inlineall.html

My markup is as so:

<div contenteditable='true'>Mycontent</div>

Using jQuery I want to be able to turn on/off the editor.

I have tried setting contenteditable to false, but this does not work. The editor is not loading back into the page on toggling the contenteditable setting.

Addendum: I also needed to destroy all CKEditor inline instances on a button click. Here is how I did that:

        //kill all ckeditors
        for(k in CKEDITOR.instances){
            var instance = CKEDITOR.instances[k];
            instance.destroy();
        }

回答1:


jQuery won't help you. Use CKEditor's API. E.g. you can destroy editor each time you want to turn it off (see http://nightly-v4.ckeditor.com/ckeditor_api/#!/api/CKEDITOR.editor-method-destroy) and initialize again to turn it on. There may be other ways to "turn editor off", but you'd have to be more precise what does it mean for you.



来源:https://stackoverflow.com/questions/12845850/turning-ckeditor-4-inline-editing-on-and-off-with-javascript

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