It's better to set initial content directly on the DOM instead of editor.setContent(), because the latter one will fail before the editor has completely been set up.
A Pen by Balazs Ree on CodePen.
| <div> | |
| <h1>TinyMCE setting initial content from js</h1> | |
| <form method="post" action="something"> | |
| <textarea name="content" cols="100" rows="15">Type Your Text</textarea> | |
| <input type="submit" value="Save" /> | |
| </form> | |
| </div> |
| $('textarea').html('<p>New content</p>'); | |
| tinymce.init({ | |
| selector: "textarea" | |
| }); |
It's better to set initial content directly on the DOM instead of editor.setContent(), because the latter one will fail before the editor has completely been set up.
A Pen by Balazs Ree on CodePen.