jquery - CKEditor setData() 不使用模态表单
问题描述
我的网页上有两个 CKEditor 实例:第一个与其他表单输入一起用于将记录添加到引导表;另一个用于以模态形式编辑该记录。
我尝试了 setData() 的所有不同组合:
抛出错误(有或没有回调):
var editorModal = CKEDITOR.replace( 'editRemarks', {
customConfig: '/contest/common/js/ckeditor_config_wf.js'
});
editorModal.setData( [row.htmlRemarks], {
callback: function() {
this.checkDirty(); // true
}
} );
这不会引发错误,但不会设置数据:
editorModal.on( "instanceReady", function( event ){
editorModal.setData([row.htmlRemarks]);
});
在后一种情况下,一旦显示模式,我可以从控制台设置内容,如下所示:
editorModal.setData('<p>Hello World</p>');
由于表格最多可以包含 10 条记录,因此我需要动态更新模态表单输入(通过表格行上的编辑按钮)。我究竟做错了什么?
CKEditor v4.15.1 • 2020 年 9 月 11 日
编辑 我的主窗体使用 CKEditor 实例向条目添加注释,然后单击“添加模型条目”按钮将其添加到下表中。
然后,用户可以通过单击编辑图标来编辑详细信息,这会弹出一个模式表单:
我的配置文件中的插件列表:
config.extraPlugins = 'button,dialog,panelbutton,colorbutton,colordialog,wordcount,notification,htmlwriter,confighelper,autogrow';
它现在才起作用,因为我在编辑按钮单击上设置了实例:
if (CKEDITOR) {
if (!editorModal) {
editorModal = CKEDITOR.replace('editRemarks', {
customConfig: '/contest/common/js/ckeditor_config_wf.js'
});
}
}
...并在保存时将其销毁:
if (editorModal) {
editorModal.destroy();
editorModal = undefined;
}
解决方案
推荐阅读
- java - 如何在机器人框架中将 Http 客户端响应转换为字典
- javascript - 在 chart.js 中自定义隐藏/显示
- cmake - 尝试使用 cmake 在 Windows 上构建 mbedtls
- bash - 如何将带引号的字符串拆分为shell中的数组
- docker - 无法在 Windows 10 中使用命令提示符登录到 docker
- javascript - 通过Javascript逻辑在ant标签中启用多选选项
- c# - 将 JArray 拆分为多个数组
- firebase - 访问字段键:来自当前用户的已验证用户的值对
- java - Jtable添加带有字符串和双打的行
- r - R freezes when trying to install packages using install.packages