问题
Hi I have problem when I need to get the content from multiple text areas. So i saw that tinyMCE has methods to take content from specific text area or from active one, but how to do it will all text areas that i have ( note : Text areas count is not static ).
I was thinking for variant to create dynamic ID of each text area and when i need to submit the content to iterate thru all of them. Something like that:
for 0 to my textareas length
var all content = tinyMCE.get('area1').getContent();
var all content += tinyMCE.get('area2').getContent();
Something like that but i don't know if this is the right way. Please help me to solve that issue. Thanks in advance
回答1:
Tinymce stores all its editors in an array: tinyMCE.editors
.
All you need to do is to loop through them and access the content:
for (i=0; i < tinyMCE.editors.length; i++){
var content = tinyMCE.editors[i].getContent();
alert('Editor-Id(' + tinyMCE.editors[i].id + '):' + content);
}
回答2:
To reach multiple tinymce instances:
http://www.tinymce.com/wiki.php/API3:property.tinymce.editors
Example:
for (edId in tinyMCE.editors)
tinyMCE.editors[edId].save();
and the best way (my opinion) would be to save the content to an array:
for (edId in tinyMCE.editors)
array[edId] = tinyMCE.editors[edId].getContent();
来源:https://stackoverflow.com/questions/16016250/how-to-get-tinymce-content-from-more-than-one-text-area