Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reebalazs/2a8ed281af9c78656632 to your computer and use it in GitHub Desktop.
Save reebalazs/2a8ed281af9c78656632 to your computer and use it in GitHub Desktop.
A Pen by Balazs Ree.
<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"
});

TinyMCE setting initial content from js

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.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment