Summernote: How to get and remove all instances of summernote?

Created on 13 Feb 2016  ·  3Comments  ·  Source: summernote/summernote

Testing out summernote for a single page web application with a need for an editor. The editor is great but we have to destroy instances every time the DOM is updated. Is there a way to get or remove all instances of summernote? Need to do so as the DOM reference may not be present anymore.

Also where can we view all the public method available from summernote?

Is there a doc I am missing?

Thanks!

Most helpful comment

@philleepflorence Thanks for response.
You can get and remove all instances of summernote with $.each.

$('.summernote').each(function( index ) {
  $(this).summernote('destroy');
});

https://api.jquery.com/each/

And you can also peek one of them with $.eq.

// destroy second editor
$('.summernote').eq(1).summernote('destroy');

https://api.jquery.com/eq/

All 3 comments

How did you activate summernote on your page?
We have destroy api for this - http://summernote.org/getting-started/#destroy

Sorry for the late response.

The instances are activated using $('selector').summernote(options); Using the above destroy method works, when destroying single instances.

However, the question was how to get all the instances and destroy them, for example $.fn.summernote.instances.destroy - to remove all. So in a single page web application, one can remove instances of summernote that don't exist in the DOM.

@philleepflorence Thanks for response.
You can get and remove all instances of summernote with $.each.

$('.summernote').each(function( index ) {
  $(this).summernote('destroy');
});

https://api.jquery.com/each/

And you can also peek one of them with $.eq.

// destroy second editor
$('.summernote').eq(1).summernote('destroy');

https://api.jquery.com/eq/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mldxpt picture mldxpt  ·  3Comments

ghost picture ghost  ·  3Comments

dandv picture dandv  ·  4Comments

johandanforth picture johandanforth  ·  3Comments

suya55 picture suya55  ·  3Comments