Pulling edited text from summernote textarea

  • Before version 0.7.0:
$('#summernote').code()
  • Version 0.7.0 and above:
$('#summernote').summernote('code')

TomPHP solution does not work with the newer version of summernote. In case anyone stumbles upon this post here is a current solution.

var textareaValue = $('#summernote').summernote('code');

Instead of Getting the value of the Field You can use the summernote code() Function.

var textareaValue = $("#summernote").code();

For Your Code:

var textareaValue = $("#content").code();

If you have a lot of Summernote objects, then you can use this script to auto-create "hidden" input elements in a form and update summernote value to each of them. This works great for my needs.

$(function(){

        // Reference each summernote object
        var summernoteObjects = [
            'summernote_id1',
            'summernote_id2',
            'summernote_id3',
            'summernote_id4',
            'summernote_id5',
            'summernote_id6',
            'summernote_id7',
            'summernote_id8',
        ];

        // Create hidden values for each summernote
        for(var i=0; i<summernoteObjects.length; i++){
            var objectPointerName = summernoteObjects[i];

            $("#" + objectPointerName).summernote();
            $("#formId").append("<input type='hidden' name='"+objectPointerName+"'>");
        }

        // Update hidden values on form submit
        $("#formId").submit(function(){
            for(var i=0; i<summernoteObjects.length; i++){
                var objectPointerName = summernoteObjects[i];
                var summernoteValue = $("#" + objectPointerName).summernote('code');

                $("#formId input[name='"+objectPointerName+"']").val(summernoteValue);
            }
        });

    });