I have 2 textarea in a webpage which use tinyMCE.
<textarea id="id1" rows="10" cols="50" name="name1"></textarea>
<textarea id="id2" rows="10" cols="50" name="name2"></textarea>
On version 3 of TinyMCE, I was able to do this
$('#id1').tinymce().execCommand('mceInsertContent', false, "content");
Now on version 4, I try to use the same code, but it didn't work. So, how can I insert content into the specific targeted textarea?
There are several possible ways.
In case your editor with "id1" is the active Editor:
tinymce.activeEditor.execCommand('mceInsertContent', false, 'your content');
In case you want to use the id:
tinymce.get("id1").execCommand('mceInsertContent', false, 'your content');
In case you only have two editors and your editor with "id1" has been initialized first:
tinymce.editors[0].execCommand('mceInsertContent', false, 'your content');
It actually can be done with
tinymce.get("id1").execCommand('mceInsertContent',false,"content");
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