I want to clear tinymce content and add new content. i tried with following code but its getting append to the old content. how can clear the existing content from tinymce.
tinymce.activeEditor.execCommand('mceCleanup');
tinymce.activeEditor.execCommand('mceInsertContent', false, result.content);
The TinyMCE getContent and setContent methods You can do this using the getContent() API method. Let's say you have initialized the editor on a textarea with id=”myTextarea”. This will return the content in the editor marked up as HTML.
</p></textarea> <br><br> <label class="container">Editable ("design") mode <input type="checkbox" checked onclick="toggleEditorMode(this. checked); return true;"> <span class="checkmark"></span> </label> <br> Use the checkbox to toggle between the "design" and "readonly" modes.
tinymce. remove() tinymce. destroy() tinymce. execCommand('mceRemoveControl',true,'.
Use :
tinyMCE.activeEditor.setContent('');
Sets the specified content to the editor instance, this will cleanup the content before it gets set using the different cleanup rules options.
Reference:TinyMce
Hope it helps.
TinyMCE provides a method setContent. Use this method to set new value.
tinymce.activeEditor.setContent("content");
Similarly it provides getContent()
tinymce.activeEditor.getContent();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With