ckeditor content into textarea on change event - multiple ckeditors on form

∥☆過路亽.° 提交于 2019-11-30 07:23:06
user3354539

For each instance of the ckeditor that you want to install on your page, add the following code to your jquery script:


CKEDITOR.instances['id_of_text_area'].on('change', function() { CKEDITOR.instances['id_of_text_area'].updateElement() });


The above JavaScript should replace the code I have displayed in the original question.

I hope this will help some one.

In case you replace textarea elements by class name, just do this:

CKEDITOR.on('instanceReady', function(event) {
    var editor = event.editor;

    editor.on('change', function(event) {
        // Sync textarea
        this.updateElement();
    });
});

The code you have written will update the textarea of only one CKEditor at a time since it is adding a change event to each CKEditor. So this will always update the last element that has been changed.

The way I handle updation of multiple CKEditors is by using this code when submitting my form

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