bootstrap Summernote reset/clear

maxlk picture maxlk · Apr 2, 2015 · Viewed 19.7k times · Source

I would like to know how to reset or clear the bootstrap Summernote WYSIWYG editor using jQuery or JavaScript.

I tried below codes

$('#MyForm').delay(1000).resetForm(1000);

This dose reset the whole form except for the textarea with the Summernote

$('#SummernoteText').reset();

SummernoteText is the html textarea but the code doesn't do anything at all.

$('#SummernoteText').destroy();

Above seems to distroy the editor instead of clearing the editor.

Can someone point me out the way to do this.

Link to Summernote http://summernote.org/#/

Answer

naribo picture naribo · Oct 19, 2018

A little late, but just to add:


Option 1:

$('#SummernoteText').summernote('reset');

This solution will only work if your editor was initially empty

This will reset your editor to its original state. Meaning, if you initialized it with any data, the same data will re-appear on reset.


Option 2:

$('#SummernoteText').summernote('code', '<p><br></p>');

The reason for adding the <p><br></p> tags instead of just plain '' is that summernote editing area needs it for focus. (Reference)