问题描述
我有一个CKEditor的textarea的:
I have a CKEditor textarea:
<textarea cols="80" id="taBody" name="taBody" class="ckeditor" rows="10" runat="server"></textarea>
我有jQuery的尝试设置从数据库中的值:
I have jQuery trying to set the value from the database:
$('#ContentPlaceHolder_taBody').val(substr[5]);
不要担心子我已经测试了它返回一个字符串。出于测试目的,我改为测试的子字符串,并接受了同样的问题。
Don't worry about the substring I already tested that it is returning a string. For testing purposes I replaced the substring with 'test' and was receiving the same issue.
我知道,围绕这一行jQuery的不影响,因为其他文本框我想填充的工作。只是当它涉及到的CKEditor。
I know that the jquery surrounding this line doesn't affect it because the other textfields I'm trying to populate work. Just when it comes to the ckeditor.
下面是整个脚本:
function (obj) {
$.ajax({
type: "POST",
url: "ContentSections.aspx/GetContentDetails",
data: '{"nodeID": "' + obj.attr('id') + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var str = msg.d;
var substr = str.split('|||');
$('#ContentPlaceHolder_hfContentSectionID').val(substr[0]);
$('.txtAlias').val(substr[1]);
$('.txtBrowserTitle').val(substr[2]);
$('.txtMetaDescription').val(substr[3]);
$('.txtMetaKeywords').val(substr[4]);
$('#ContentPlaceHolder_taBody').val(substr[5]);
}
});
}
的问题是,什么也没有被填充,并正在显示没有JavaScript错误。
The issue was that nothing was being populated and no javascript errors were being shown.
我想读左右,但找不到任何东西,帮助我。有没有人有什么想法?
I tried to read around but couldn't find anything that helped me. Does anyone have any ideas?
推荐答案
您需要使用的CKEditor的API,而不是。
You need to use CKEditor's API instead.
具体而言,http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setData
这篇关于使用jQuery设置CKEditor的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!