Saving Multiple TinyMCE Instances

I have several instances of TinyMCE on one page.

I have a javascript autoload running in the background that automatically saves forms in the database via a POST request. This works well with one form, where I can set the item id to init. However, in my scenario, the user may have a variable number of TinyMCE forms, so having multiple hard-code identifiers does not seem practical.

TL; DR: dynamically capture all TinyMCE instances on the same page without knowing the instance id. Or any other approach to save multiple forms in one auto_save () function.

+7
source share
2 answers

What Brett described is correct. Here is the code that you can call if necessary, i.e. In your auto_save () function:

for (var i = 0; i < tinymce.editors.length; i++) { // you need to do what is needed here // example: write the content back to the form foreach editor instance tinymce.editors[i].save(); } 
+6
source

You can iterate through tinyMCE.editors in your auto_save () function.

+4
source

All Articles