当我在div ckeditor
上添加contenteditable="true"
时,它运行正常。有一个add more
按钮。当我单击该按钮时,会添加div但未加载ckeditor
。如何让ckeditor
工作?
答案 0 :(得分:0)
您需要为您刚刚添加到文档中的每个div[contenteditable="true"]
调用CKEDITOR.replace
方法。
您可以使用以下代码实现它:
var res = CKEDITOR.document.find( 'div[contenteditable="true"]' ),
// Your editor config goes here.
editorConfig = {};
for ( var i = 0; i < res.count(); i++ ) {
var curElement = res.getItem( i );
if ( !curElement.getEditor() ) {
// We only want to process elements that have have no editor yet.
CKEDITOR.replace( curElement, editorConfig );
}
}
如果您想要创建内联编辑器,则需要使用CKEDITOR.inline
重新CKEDITOR.replace
。
if ( !curElement.getEditor() ) {
// We only want to process elements that have have no editor yet.
CKEDITOR.inline( curElement, editorConfig );
}