Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset TinyMCE box

I am using TinyMCE editor. I want to clear the content inside the editor box with some button click present on my form.

Can you let me know how to do so?

like image 678
Rocky Singh Avatar asked May 23 '11 15:05

Rocky Singh


2 Answers

This can be easily done (no need to use the slow jQuery tinymce build) using the following code as onclick-action of your button:

// 'content' is tinymce default,
// but if your textarea got an ID that is the one you need!
var my_editor_id = 'content';

// set the content empty
tinymce.get(my_editor_id).setContent(''); 
like image 59
Thariama Avatar answered Oct 04 '22 04:10

Thariama


From the TinyMCE jQuery Plugin documentation, can be easily found from the page you linked:

// Will change the contents of an textarea with the ID "someeditor"
$('#someeditor').html('Some contents...');

// Will change the contents all text areas with the class tinymce
$('textarea.tinymce').html('Some contents...');

// Gets the contents from a specific editor
alert($('#someeditor').html());

Try setting it to empty string, might be just what you need.

like image 43
DarthJDG Avatar answered Oct 04 '22 03:10

DarthJDG