修改內(nèi)容時(shí)修改富文本的內(nèi)容時(shí),首先要拿到內(nèi)容,如何拿到富文本的內(nèi)容呢?
富文本有個(gè)getData()方法
var ed = this.editor
// ckedtior有四個(gè)狀態(tài) unloaded, loaded, ready, destroyed 到ready的時(shí)候setData方法才有效
var waitCKEditorReady = function(data) {
if(ed.status == 'ready') {
ed.setData(data);
} else {
setTimeout(function() {
waitCKEditorReady(data);
}, 20);
}
}
setTimeout(function() {
waitCKEditorReady(ckcontents);
}, 50);