I want to set a content of tinyMCE editor after it was created with an AJAX request. I have several editors on page. All them are initialised with:
tinymce.init({
selector: '.tiny-mce'
});
Each editor has a distinct class to separate it from each other.
How do I use this class to set content to a one particular editor, after getting data with an AJAX request?
tinyMCE.get('.class_name') // returns null
I am searching API and SO and can't find a function to do such a simple thing.
Edit:
I found not so clean way to get the editor instance. When tinyMCE was created it added id with editor name to the element. Now I can do something like this:
var id = $('.class_name').attr('id');
tinyMCE.get(id).setContent('new content');
But is there a better way?