Multiple instances of CKEditor (in Safari) [duplicate]

我的未来我决定 提交于 2019-12-06 11:03:20

this is what i've done:

var CKeditors = {};
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';
            var html = '';
            if( $(this).val() ){
                html = $(this).val();
            }
            CKeditors[editorID] = CKEDITOR.appendTo(dst, {}, html);
        });
        $("textarea.ckeditor").hide();
    }
}

function updateCKEditors() {
    for(x in CKeditors){
        $("#"+x).val(CKeditors[x].getData());
    }
}

then after ajax succes im doing

loadEditors()

and before form submitting (for example using ajax):

updateCKEditors()

you need jQuery to have that working. this is for zend_forms, but after few corrections should work in normal forms too. play with 'dst' to do that.

Tom Cool

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

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, {});
        });
    }
}

what I do:

var instance = CKEDITOR.instances['test'];
instance.destroy();
instance = null;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!