Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE insert content

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?

like image 208
user1995781 Avatar asked Apr 10 '14 01:04

user1995781


2 Answers

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');
like image 92
Thariama Avatar answered Nov 15 '22 22:11

Thariama


It actually can be done with

tinymce.get("id1").execCommand('mceInsertContent',false,"content");
like image 21
user1995781 Avatar answered Nov 15 '22 21:11

user1995781