Reputation: 9037
is it possible or can I initialize two textarea's with tinyMCE editor? I know I can set content to tinyMCE editor using (refer below)
tinyMCE.activeEditor.setContent('test');
but what if I want to set content to a specific already tinyMCE editor initialized textarea e.g. the second textarea, is that even possible? or is there a way to do that?
Any help, ideas, clues, suggestions, recommendations is greatly appreciated. Thank you.
tinymce.init({
selector: 'textarea',
height: 230,
theme: 'modern',
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<textarea id="t1"></textarea><br>
<button id="t1button">Set content to tinyMCE textarea 1</button><br><br>
<textarea id="t2"></textarea><br>
<button id="t2button">Set content to tinyMCE textarea 2</button><br>
Upvotes: 0
Views: 2706
Reputation: 13746
You can target a specific TinyMCE editor using the get API method:
https://www.tinymce.com/docs/api/class/tinymce.editormanager/#get
For example:
tinyMCE.get('t2').getContent()
tinyMCE.get('t2').setContent('...content here...')
...would target the TinyMCE instance that has a selector of an ID of 't2 '.
Upvotes: 1