Quick Tip / Fix – SummerNote Editor resize editor after using ‘reset’

I’ve been using recently the Summernote Editor in a project and at a certain point of time, one action was to load a template (saved rich text) into the editor and remove the old text that might be there.

When the editor was initialized the resize of it was working fine, after ‘pasting’ the loaded template inside the editor, it was not working anymore, which is not really OK.

 

This is how I was posting the loaded text (AJAX call was returning it on change of a select drop down).

$('#footer-message').summernote('reset');
$('#footer-message').summernote('editor.pasteHTML', response.data.text);

And here you can see how it was reacting correctly on load and after posting not allowing to resize the editor anymore:

summernote breaks after reset

It seems that using ‘reset‘ affects the editor in such a manner that the resize bar is removed from the HTML.

To prevent this I’ve simply replaced that line with the following:

$('#footer-message').summernote('code', '');

 

This way, I get the expected behavior: the old text inside the editor is removed and replaced by the new one and, most important, the editor is still resizable.

 

If you like this and find it useful please consider sharing it! Cheers!Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
 

C