I have multiple instances of TinyMCE on one page.
I have a javascript autosave running in the background that automatically saves the forms in the database via a POST request. This works good with one form where I can set the element ID in the init. However, in my scenario, the user can have a variable number of TinyMCE forms, so having multiple hardcoded element ID's do not seem practical.
TL;DR: Dynamically grab all instances of TinyMCE in the same page without knowing the instance ID. Or, any other approach to save multiple forms in one auto_save() function.
The way Brett decribed is correct. Here is the code you may call whenever needed, 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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With