我正在尝试在我的网站上使用 CKeditor。我发现在 Source 模式 中时,已被 ckeditor 替换的文本区域未更新。我需要更新文本区域,因为页面上的代码设置为在保存时保存文本区域内容。
在正常模式下,文本正在更新。
$(document).ready(new function() {
var editor = CKEDITOR.instances['content-text'];
if (editor) { editor.destroy(true); }
CKEDITOR.on('instanceCreated', function(e) {
e.editor.on('contentDom', function() {
e.editor.document.on('keyup', function(event) {
// keyup event in ckeditor
UpdateTextArea();
});
});
});
CKEDITOR.replace('content-text');
});
function UpdateTextArea() {
CKEDITOR.instances['content-text'].updateElement();
}
非常感谢任何帮助。这是我第一次提出问题,如有遗漏,请见谅!
最佳答案
我有点傻。
在输入按钮的 onclick 事件中,我只需要添加:
function UpdateTextArea() {
var editor_data = CKEDITOR.instances['content-text'].getData();
$('#content-text').html(editor_data);
}
关于javascript - CKeditor 不更新源代码模式下的文本区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12071145/