How change the CKEditor text using jQuery?

痴心易碎 提交于 2019-12-01 18:01:35

You can't simply add text to the CKEDITOR via jQuery, instead go with api given by CKEDITOR

CKEDITOR.instances.editor1.setData(data.data.description); 

Here your code looks like

$.getJSON('http://gdata.youtube.com/feeds/api/videos/'+video_id+'?v=2&alt=jsonc',function(data,status,xhr){   
    CKEDITOR.instances.editor1.setData(data.data.description); 
});

Fiddle

Instead of writing the description directly into the text area, try the CKEditor setData method. You can find a description of it here:

http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-popup

also be sure that your description variable does have a value, I'd use a temporary alert(description); for this but you may be able to do it with a javascript debugger also.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!