Question

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?

Was it helpful?

Solution

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');

OTHER TIPS

It actually can be done with

tinymce.get("id1").execCommand('mceInsertContent',false,"content");

Try with your dom id as arguement:

tinymce.get("YOUR DOM ID").execCommand('mceInsertContent',false,'use your output content');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top