Setting content into multiple TinyMCE textarea?

别说谁变了你拦得住时间么 提交于 2020-01-13 18:25:35

问题


I have 3 tinymce textarea, in my page. And I want to populate these text areas from ajax.

I know the name of the original textarea field, but

tinyMCE.activeEditor.setContent(value);

does not work, since I dont have any active editor.

Here is a basic example of my code

.
.
.
function(data) {
$.each(data, function(key,value)) {
    $("#"+key).val(value); //"#"+key is the id of tinymce editors in my form
},
"json"
.
.
.
.

回答1:


Try this

for(i=0; i < tinymce.editors.length; i++){
    tinymce.editors[i].setContent(value);
}

Edit: You may also use the following

for(i=0; i < tinymce.editors.length; i++){
    tinymce.get(tinymce.editors[i].id).setContent(value);
}



回答2:


if you are using the tinyMCE jquery editor you can try the following code

$.each(tinyMCE.editors, function(index, editor){
     editor.setContent(value);
);


来源:https://stackoverflow.com/questions/5553716/setting-content-into-multiple-tinymce-textarea

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