在变更事件中将ckeditor内容转换为textarea - 表单上有多个ckeditors

use*_*539 7 jquery ckeditor

在很多帮助下,我终于让CKEditor更新了相关的文本区域.请看这里的帖子.

但是,当表单上有超过1个CKEditor时,我很难理解如何让CKEditor更新每个相关的文本区域.

这是我目前拥有的jquery.它只更新表单上的最后一个CKEditor关联文本区域:

    for (var i in CKEDITOR.instances) {
        CKEDITOR.instances[i].on('change', function() { CKEDITOR.instances[i].updateElement() }); //update the relative hidden textarea.
    }
Run Code Online (Sandbox Code Playgroud)

当表单上有5个或10个CKEditor时,如何更新每个关联的CKEditor文本区域?

use*_*539 12

对于要在页面上安装的每个ckeditor实例,请将以下代码添加到jquery脚本中:


CKEDITOR.instances['id_of_text_area'].on('change', function() { CKEDITOR.instances['id_of_text_area'].updateElement() });
Run Code Online (Sandbox Code Playgroud)


上面的JavaScript应该替换我在原始问题中显示的代码.

我希望这对一些人有所帮助.