javascript - ckeditor初始化并销毁

标签 javascript jquery ckeditor

我知道在 stackoverflow 或 google 上也有类似的问题,但到目前为止没有任何帮助.. 我在最新的稳定版本中使用带有 jquery 适配器的 ckeditor。

点击后退和前进后,我在 firebug 中收到以下错误:

uncaught exception: [CKEDITOR.editor] The instance "cause" already exists

当我现在尝试通过以下方式破坏编辑器时:

var editor=jQuery("#cause").ckeditorGet();
editor.destroy();

我得到以下错误:

CKEditor not yet initialized, use ckeditor() with callback.

如果我尝试逐步重现问题(后退/前进按钮除外) 我在 Firebug 中有一些不同的行为

创建一个新的ckeditor

jQuery('#cause').ckeditor();

再次销毁编辑器

var editor=jQuery('#cause').ckeditorGet();
editor.destroy();

尝试重新创建编辑器失败(没有任何警告或错误)

jQuery('#cause').ckeditor();

结果: 文本区域保持不变

预期结果: 小编又上来了

任何帮助将不胜感激

最佳答案

我发现如果事先没有初始化它会崩溃。然而,这有效。

销毁实例。 (假设您有一个名为 CKEDITOR 的全局变量。

if(CKEDITOR){
    if(CKEDITOR.instances.editor1){
        CKEDITOR.instances.editor1.destroy();
    }
}

关于javascript - ckeditor初始化并销毁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8925094/

相关文章:

javascript - 如果调用函数时提供的参数包含空格,则不会调用函数

javascript - Fancybox 未加载 href 中给出的某些网站

jQuery; Django ;解析http响应

javascript - 使用 javascript 管理 MVC 复选框

html - CKEditor尊重 block 元素

javascript - 我可以将变量设置为对象的多部分属性吗?

javascript - 使用变量而不是 $(this) 是一种好习惯吗?

javascript - 在正则表达式中使用变量 (jQuery)

angular - CKEDITOR5 - Angular8 : TypeError: this. editor.create 不是函数

JQuery 没有检测到 div 的更改