我有来自数据库的数据.
在我的js文件中,我想更改我的CKEditor文本编辑器的值.
我的价值是原始的html.
我希望将这个原始值写在空的CKEditor文本编辑器上.
我试过这些但是一直有一个未定义的函数错误:
CKEDITOR.instances.myEditorID.insertHtml( '
This is a new paragraph.
' );CKEDITOR.instances.myEditorID.setData( '
This is the editor data.
' );我也尝试了这个但仍未定义函数错误:
CKEDITOR.instances.YOUREDITORID.updateElement();
alert( document.getElementById( 'YOUREDITORID' ).value );
而不是myEditorID,我试过'编辑','editor1','editor2',但仍然不适合我.
提前致谢.
---更新---
这是我的ckeditor文本编辑器的html:
$(function () {
var myEditor = $('#myEditorID');
myEditor.ckeditor({
height: 200,
extraPlugins: 'charcount',
maxLength: 2000,
toolbar: 'TinyBare',
toolbar_TinyBare: [
['Bold','Italic','Underline'],
['Undo','Redo'],['Cut','Copy','Paste'],
['NumberedList','BulletedList','Table'],['CharCount']
]
}).ckeditor().editor.on('key', function(obj) {
if (obj.data.keyCode === 8 || obj.data.keyCode === 46) {
return true;
}
if (myEditor.ckeditor().editor.document.getBody().getText().length >= 2000) {
alert('You have reached the maximum char length');
return false;
}
});
});