CKEditor的多个实例(在Safari中) [英] Multiple instances of CKEditor (in Safari)

查看:736
本文介绍了CKEditor的多个实例(在Safari中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JQuery UI对话框中创建多个CKEditor实例时遇到问题。该对话框通过AJAX加载一个远程表单,所以目标是能够关闭并重新打开对话框并拥有一个新的编辑器实例。使用默认选项,当重新打开对话框时,它会给出一个错误,指出具有该名称的编辑器已存在。所以我尝试了几种破坏编辑器实例的方法,它们都导致相同的问题。当编辑器重新加载时,文本区域为空,按钮不起作用。

I'm having a problem creating multiple instances of a CKEditor in a JQuery UI dialog. The dialog loads a remote form via AJAX, so the goal is to be able to close and reopen the dialog and have a new instance of the editor. With the default options, when reopening the dialog it gives an error saying that an editor with that name already exists. So I have tried several methods of destroying the editor instance and they all result in the same problem. When the editor is reloaded, the text area says null and the buttons don't function.

目前我正在使用此方法销毁实例:

Currently I'm using this method of destroying the instance:

var instance = CKEDITOR.instances['test'];
if (instance) { CKEDITOR.remove(CKEDITOR.instances['test']); }

我重新创建了一个可供下载的简单html文件的问题此处

I recreated the issue with a couple of simple html files available for download here.

编辑:我刚刚尝试使用两个远程文件,文本区域有不同的名称,我有相同的问题。当一个对话框打开然后关闭时,另一个对话框打开时有一个nullCKEditor。

I just tried using two remote files with a text area that has a different name and I have the same problem. When one dialog is opened and then closed, the other dialog has a "null" CKEditor when it is opened.

另外,显然这只是Safari中的一个问题。 / p>

Also, apparently this is only a problem in Safari.

推荐答案

一个老主题的位,但我有一个类似的问题。

Bit of an old topic, but i had a similar problem.

我使用activ的解决方案,这是非常好的!
CKEDITOR.appendTo 没有为我工作,但稍后修改 loadEditors 函数:

I used activ's solution above, which worked out great! CKEDITOR.appendTo did't work out for me, but with the next slight modification to the loadEditors function it did:

function loadEditors() {
    var $editors = $("textarea.ckeditor");
    if ($editors.length) {
        $editors.each(function() {
            var editorID = $(this).attr("id");
            if(CKeditors[editorID]){
                CKeditors[editorID].destroy();
                CKeditors[editorID] = null;
            }

            var dst = editorID+'-element';
            CKeditors[editorID] = CKEDITOR.replace(dst, {});
        });
    }
}

这篇关于CKEditor的多个实例(在Safari中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆