Search code examples
javascriptjquerysummernote

Having issues appending text to Summernote element on change event


I am using summernote for wysiwyg editor. I am trying to append text to the selected element.

I have tried to append the text to the .note-editable that is created by the summernote script with no luck

<script>
  $('#selector').on('change', function () {

    let currentTemplate = 'This will come from db';

    $('.note-editable').html(currentTemplate);

    $('#email_body').summernote();
  });
 </script>

On change, the wysiwyg editor should be filled with the text from db. This will update every time a different selection is made.


Solution

  • Switch your code like this:

    $('#selector').on('change', function () { let currentTemplate = 
    'This will come from db'; 
    $('#email_body').summernote(); 
    $('.note- editable').html(currentTemplate);});