Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting content into multiple TinyMCE textarea?

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"
.
.
.
.
like image 778
mrN Avatar asked Aug 05 '26 17:08

mrN


1 Answers

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);
}
like image 135
Thariama Avatar answered Aug 07 '26 06:08

Thariama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!