CKEditor实例已存在 [英] CKEditor instance already exists
问题描述
我使用jquery对话框来呈现表单(通过AJAX提取)。在一些形式我使用CKEditor的textareas。第一次加载时,编辑器显示正常。
当用户取消对话框时,我将删除内容,以便在以后的请求中加载新内容。问题是,一旦重新加载对话框,CKEditor声称编辑器已经存在。
未捕获异常:[CKEDITOR.editor]实例textarea_name已存在。
API包括一个破坏现有编辑器的方法,我已经看到人们声称这是一个解决方案:
if(CKEDITOR.instances ['textarea_name']){
CKEDITOR.instances ['textarea_name']。 ();
}
CKEDITOR.replace('textarea_name');
这不适合我,因为我收到一个新错误:
TypeError:表达式的结果'i.contentWindow'[null]不是一个对象。
这个错误似乎发生在destroy()而不是replace有没有人遇到过这个问题,并找到了不同的解决方案?
是否可以重新渲染现有的编辑器,而不是销毁和替换? b
$ b
UPDATED
这里是另一个问题,处理相同的问题,但他提供了可下载的测试用例。 / p>
要解决此问题,您需要在销毁实例时传递布尔参数 true :
var editor = CKEDITOR.instances [name];
if(editor){editor.destroy(true); }
CKEDITOR.replace(name);
I am using jquery dialogs to present forms (fetched via AJAX). On some forms I am using a CKEditor for the textareas. The editor displays fine on the first load.
When the user cancels the dialog, I am removing the contents so that they are loaded fresh on a later request. The issue is, once the dialog is reloaded, the CKEditor claims the editor already exists.
uncaught exception: [CKEDITOR.editor] The instance "textarea_name" already exists.
The API includes a method for destroying existing editors, and I have seen people claiming this is a solution:
if (CKEDITOR.instances['textarea_name']) {
CKEDITOR.instances['textarea_name'].destroy();
}
CKEDITOR.replace('textarea_name');
This is not working for me, as I receive a new error instead:
TypeError: Result of expression 'i.contentWindow' [null] is not an object.
This error seems to occur on the "destroy()" rather than the "replace()". Has anyone experienced this and found a different solution?
Is is possible to 're-render' the existing editor, rather than destroying and replacing it?
UPDATED Here is another question dealing with the same problem, but he has provided a downloadable test case.
For this to work you need to pass boolean parameter true when destroying instance:
var editor = CKEDITOR.instances[name];
if (editor) { editor.destroy(true); }
CKEDITOR.replace(name);
这篇关于CKEditor实例已存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!