Answer the question
In order to leave comments, you need to log in
How to add text to dynamically added tinymce?
tinyMCE.get('.text_edit_news-1').setContent("HELLO");
Throws an error
Uncaught TypeError: Cannot read property 'setContent' of null
Initialization is like this
tinymce.init({
selector: '.tinymceeditor', ...
Each textarea has an additional class text_edit_news-1, text_edit_news-2
After clicking the button, AJAX get the data and I want to drive them into the editor, but it does not work ...
Answer the question
In order to leave comments, you need to log in
Found an answer to your question.
It is necessary not to prescribe a class in the textarea, but to make the ID unique, after which it will be possible to access
it tinymce.get('text_edit_news-'+k).setContent(result[i].text);
where k is an index from the array :)
The error was that I was trying to access via a class even though tinymce documentation says ID and not class..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question