使用JavaScript打开和关闭CKEditor 4内联编辑 [英] Turning CKEditor 4 inline editing on and off with JavaScript
问题描述
我需要能够使用按钮开启/关闭内嵌编辑。请参阅此处的内联编辑示例: http://nightly-v4.ckeditor.com /3559/samples/inlineall.html
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
我的标记如下:
<div contenteditable='true'>Mycontent</div>
使用jQuery我想能够打开/关闭编辑器。
Using jQuery I want to be able to turn on/off the editor.
我已经尝试将 contenteditable
设置为false,但这不起作用。编辑器未在切换到 contenteditable
设置的页面上加载。
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.
补充:我还需要销毁所有CKEditor内联实例上的一个按钮点击。这是我怎么做的:
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();
}
推荐答案
jQuery不会帮助你。使用CKEditor的API。例如。您可以在每次要将其关闭时销毁编辑器(请参阅 http:/ /nightly-v4.ckeditor.com/ckeditor_api/#!/api/CKEDITOR.editor-method-destroy ),然后再次初始化以将其启用。可能还有其他方法可以关闭编辑器,但是你必须更精确地说明它对你意味着什么。
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.
这篇关于使用JavaScript打开和关闭CKEditor 4内联编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!