【问题标题】:Changing order of two divs with CKEditors使用 CKEditors 更改两个 div 的顺序
【发布时间】:2015-08-28 19:45:19
【问题描述】:

我有两个 CKEditor,由 Liferay 脚本创建,在我看来,一个一个。两者都在单独的div中。我想改变它的顺序。

我尝试使用这样的东西:

var firstDivWithCKEditor = document.getElementById("firstDivWithCKEditor");
var secondDivWithCKEditor = document.getElementById("secondDivWithCKEditor "); 
var parentDiv = secondDivWithCKEditor.parentNode();
parent.insertBefore(secondDivWithCKEditor , firstDivWithCKEditor);

顺序已更改,但在此操作之后,我无法在一个编辑器上执行任何操作,并且编辑器内的 html 消失了。单击编辑器中的任何按钮后,我在控制台上收到错误:未捕获的类型错误:无法读取未定义的属性“getSelection”。

有人知道哪里出了问题吗?

【问题讨论】:

    标签: javascript ckeditor liferay liferay-6


    【解决方案1】:

    经典(基于iframe)的编辑器实例无法做到这一点。不过,您可以轻松地重新初始化您的实例 (JSFiddle):

    var e1, e2,
        el1 = CKEDITOR.document.getById( 'editor1' ),
        el2 = CKEDITOR.document.getById( 'editor2' );
    
    function initEditors( reverse ) {    
        if ( e1 || e2 ) {
            e1.destroy();
            e2.destroy();        
        }
    
        ( reverse ? el2 : el1 ).insertBefore( ( reverse ? el1 : el2 ) );
    
        e1 = CKEDITOR.replace( el1 );
        e2 = CKEDITOR.replace( el2 );
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-12
    • 2021-05-25
    • 2014-10-31
    • 2021-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多