CKEDITOR inline on dynamic created element ( droppable/sortable )

旧街凉风 提交于 2019-12-04 20:24:58

we are also facing same issue when we have same scenario. In that user drag drop editor type element on page on clicking that he is able to enter text.

we find that CKeditor is bind with physical DOM element which is already present on page at time to execute '$(document).ready()' function not with dynamically added element.

So we are create one div with contenteditable="true" and add inline CKeditor function in document.ready, and on click dynamic element we hide the element and show CKeditor Div exactly same width, height over dynamic element.

Then user enter some text and click outside editor we catch focusout event of CKeditor and take content inside Ckeditor and put it in our dynamic element and hide Ckeditor div and show our Element.

I'm not sure if this is the best way to handle the scenario but you could destroy existing CKEditor instances before adding new ones. E.g.,

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