Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textarea value change when summernote div is changed

Tags:

I have setup a div for the summernote to alter text pulled from a database.

<div id="summernote" class="form-control"><?php echo $laws['content']; ?></div> 

$(document).ready(function() {
   $('#summernote').summernote({
     height: 300,
   });
});

directly following the div I have a text area with an ID.

<textarea id="lawsContent"></textarea>

I want the content of the textarea to change as I type in the summernote div. Just like what is happening while I am typing this question.

like image 366
user3367639 Avatar asked Mar 03 '14 01:03

user3367639


1 Answers

Using the summernote API

I came up with this solution:

$(document).ready(function() {
    $('#summernote').summernote({
      onKeyup: function(e) {
        $("#lawsContent").val($("#summernote").code());
      },
      height: 300,
    });
});
like image 138
user3367639 Avatar answered Oct 05 '22 20:10

user3367639