CKEDITOR destroy()抛出Uncaught TypeError:无法读取未定义

时间:2015-05-15 21:12:16

标签: javascript ckeditor

我使用以下代码销毁CKEDITOR(版本4.4.7)的实例:

var ck = CKEDITOR.inline(iElm[0],options);
ck.on("blur",function() {
    this.destroy(true);
});

代码运行正常,实例从DOM中删除,但报告了以下错误:

Uncaught TypeError: Cannot read property 'checkFeature' of  undefined
checkAllowed @ ckeditor.js:178
refresh @ ckeditor.js:177
c @ ckeditor.js:920
j @ ckeditor.js:10
CKEDITOR.event.CKEDITOR.event.fire @ ckeditor.js:12
CKEDITOR.editor.CKEDITOR.editor.fire @ ckeditor.js:13
f @ ckeditor.js:215
(anonymous function) @ ckeditor.js:215
(anonymous function) @ ckeditor.js:25

知道我做错了什么吗?

2 个答案:

答案 0 :(得分:1)

我发现以下内容消除了错误消息:

var ck = CKEDITOR.inline(iElm[0],options);
   ck.on("blur",function() {
   var editor=ck.name;
   $timeout(function() {
       CKEDITOR.instances[editor].destroy();
   },0);
});

答案 1 :(得分:0)

好吧,编辑器只有我们用来保存编辑器的空div元素。那么,这样做是否有害:

CKEDITOR.instances.editor.removeAllListeners();