问题
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