我有两个 CKEditor,由 Liferay 脚本创建,在我看来是一一对应的。两者都在单独的 div 中。我想改变它的顺序。
我尝试使用这样的东西:
var firstDivWithCKEditor = document.getElementById("firstDivWithCKEditor");
var secondDivWithCKEditor = document.getElementById("secondDivWithCKEditor ");
var parentDiv = secondDivWithCKEditor.parentNode();
parent.insertBefore(secondDivWithCKEditor , firstDivWithCKEditor);
顺序已更改,但在此操作之后我无法在一个编辑器上执行任何操作,并且编辑器内的 html 消失。单击编辑器中的任何按钮后,我在控制台上收到错误:未捕获的类型错误:无法读取未定义的属性“getSelection”。
有人知道出了什么问题吗?
最佳答案
使用经典(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 );
}
关于javascript - 使用 CKEditors 更改两个 div 的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30809159/