根据与 ckeditor4 不同的文档,没有任何.CKEDITOR.instances
setData()
ajax
示例代码:
let myEditor;
ClassicEditor
.create(document.querySelector('#menuContent'), {
language: {
// The UI will be English.
ui: 'fa',
// But the content will be edited in Arabic.
content: 'fa'
},
placeholder: 'متن منو را وارد نمایید...'
})
.then(editor => {
window.editor = editor;
myEditor = editor;
})
.catch(err => {
console.error(err.stack);
});
function ShowMenuDetails(id) {
$.ajax({
url: '@Url.Action("MenuDetails", "Admin")',
type: 'POST',
data: JSON.stringify({ id: id }),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
cache: false,
success: function (data) {
$("#menuTitle").val(data.MenuTitle);
$("#order").val(data.MenuOrder);
myEditor.setData(data.MenuContent);
$("#myModal").modal();
},
error: function (err) {
alert(err);
},
statusCode: {
404: function (content) { alert(content); },
500: function (content) { alert(content); }
}
});
}