Search code examples
jquerytinymce

How to get tinyMCE content from more than one text area


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


Solution

  • 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);
    }