I got problems getting text back into the summernote editor.
I already tried (but did not work):
$(\"#EDITsummernote\").innerHtml = \'test\';
Insert Text:
$('#summernote').summernote('editor.insertText', 'hello world');
You can use this line if you want to set (paste) HTML code in editor:
$('#summernote').summernote('editor.pasteHTML', '<b>hello world</b>');
Source code
Bonus
Clear all editor content:
$('#summernote').code("");
None of the Solutions works for me until I did this.
<textarea name="description" class="form-control summernote_rpt summernote_custom"></textarea>
Let's say you have initialized summernote something like this in which I have two classes
.summernote_custom
was used
$('.summernote_rpt').summernote(options);
when the entire page loads and when I wanted to update the summernote value using js I used
$('.summernote_rpt').summernote('code','data');
$(".summernote").code("your text");
To set:
$('#summernote').summernote('code', '<b> hello world </b>');
To get:
var get_code = $('#summernote').summernote('code');
Documentation: http://summernote.org/getting-started/#get--set-code
Since v0.7.0 code()
has been deprecated and removed (same story for destroy()
method).
You must use $(".summernote").summernote("code", "your text");
Reference: https://summernote.org/getting-started/#get--set-code
After v0.7.0, direct jquery methods,
destroy
andcode
were removed for avoiding conflict with other jquery libraries. You can call this methods with summernote api.
To set text in the summernote editor:
$('#summernote').summernote('editor.insertText', 'hello world');