Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tinymce content clear mceCleanup

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);
like image 845
Rejayi CS Avatar asked Feb 27 '14 11:02

Rejayi CS


People also ask

How do I get content from TinyMCE textarea?

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.

How do you make TinyMCE readonly?

</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.

How do you destroy TinyMCE?

tinymce. remove() tinymce. destroy() tinymce. execCommand('mceRemoveControl',true,'.


2 Answers

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.

like image 167
Gopesh Avatar answered Sep 20 '22 12:09

Gopesh


TinyMCE provides a method setContent. Use this method to set new value.

tinymce.activeEditor.setContent("content");

Similarly it provides getContent()

tinymce.activeEditor.getContent();
like image 36
Nps Avatar answered Sep 18 '22 12:09

Nps