Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap Summernote reset/clear

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

like image 595
maxlk Avatar asked Apr 02 '15 18:04

maxlk


People also ask

How do I edit Summernote editor?

You can customize it with popover. air option. $('#summernote'). summernote({ popover: { air: [ ['color', ['color']], ['font', ['bold', 'underline', 'clear']] ] } });

How do I turn off Summernote?

You can disable editor by API. $('#summernote'). summernote('disable'); If you want to enable editor again, call API with enable.

How do I change my theme on Summernote?

summernote-themes Most of the themes are easily added by swapping out the CSS File in place of the original supplied by the Summernote team. In this repository we supply a minified, unminified, version using Summernote's Icons, a version using LibreICON Icons (black and colour embedded).

Does Summernote require jquery?

The Summernote Editor is a free & open-source super simple WYSIWYG editor based on Bootstrap & jQuery.


2 Answers

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)

like image 142
naribo Avatar answered Sep 29 '22 22:09

naribo


For Summernote 0.8.1 version use this simple code:

$("#SummernoteText").summernote("reset");
like image 41
Mr world wide Avatar answered Sep 30 '22 00:09

Mr world wide