[英]How to set data to CKEDITOR after CKEDITOR load?
I have HTML: 我有HTML:
<div class="form-group">
<textarea name="template_body">
</textarea>
</div>
<script>
CKEDITOR.replace('template_body');
</script>
And JS-code: 和JS代码:
var editor = CKEDITOR.instances["template_body"];
var requestGetValue = $http({
method: "get",
url: "/getValue",
dataType: 'json',
contentType: 'application/json',
mimeType: 'application/json'
});
requestGetValue.success(function (data) {
editor.setData(data);
});
But sometimes my data
was loaded to CKEDITOR, and sometimes wasn't loaded. 但是有时我的
data
已加载到CKEDITOR,有时未加载。 How to set data to CKEDITOR after load CKEDITOR? 加载CKEDITOR后如何将数据设置为CKEDITOR?
I assume the problem is with the ajax response delay. 我认为问题出在ajax响应延迟。
Try the following, 试试以下方法
var editor = CKEDITOR.replace( 'template_body' );
editor.on( 'contentDom', function(){
var requestGetValue = $http({
method: "get",
url: "/getValue",
dataType: 'json',
contentType: 'application/json',
mimeType: 'application/json'
});
requestGetValue.success(function (data) {
editor.setData(data);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.