I need to append a string (an img tag) to a tinyMCE editor instance.
I was doing it like this:
$("#textboxhiddenbytinymce").append( string );
tinyMCE.triggerSave();
with no luck. I was wondering if:
There is a direct method for adding an arbitrary string (I need complete control over it) to an instance of tinyMCE I understand that the way I'm doing it is wrong since tinyMCE works indipendently to the "original" textarea.
Thank you very much!
Current versions of TinyMCE (version 4 at the moment) put their content in an iframe. After you find the id of that iframe, something similar to the following can be used:
The only way this will work is if you use the jQuery Plugin version. Luckily it's easy to convert an existing tinyMCE.init block to use jQuery:
Then you can access the $('textarea#tinymce') object and edit it as you would a normal element.
Hope this answer is still helpful to someone a year after the question was posted!