Javascript 删除所有 CKEditor 实例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11687627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove all CKEditor instances
提问by Eric
I have a form in which I have CKEditor replacing my <textarea>
s (multiple). I want to remove all CKEditor instances from the page beforesubmitting the form. How can I accomplish this?
我有一个表格,我用 CKEditor 替换了我的<textarea>
s(多个)。我想在提交表单之前从页面中删除所有 CKEditor 实例。我怎样才能做到这一点?
I've looked at Remove CKEdit Instancebut it didn't help me at all.
我看过删除 CKEdit 实例,但它根本没有帮助我。
NOTE: All my CKEditors have a class "ckedit"
注意:我所有的 CKEditor 都有一个类“ckedit”
回答by AlfonsoML
This will destroy all CKEDITOR instances on a page:
这将销毁页面上的所有 CKEDITOR 实例:
for(name in CKEDITOR.instances)
{
CKEDITOR.instances[name].destroy(true);
}
回答by Piyush Sardana
回答by anonymousdude
Have you tried just...
你有没有试过...
delete CKEDITOR;
I had a similar situation and this worked for me. Just make sure you re-create it the next time you need to use it. Otherwise try keeping an array of id's of all the instances you create and just loop through that array and destroy them all.
我有类似的情况,这对我有用。只要确保在下次需要使用它时重新创建它。否则,尝试保留您创建的所有实例的 id 数组,然后循环遍历该数组并将它们全部销毁。