Search code examples
jquerysummernote

Get ID of Summernote Element


I am going to have multiple summernote fields on a page, and I want a dynamic way to get the element ID when doing onblur. I can't seem to get the elements id, it just comes back undefined

Example HTML

<div class="summernote" id="desc_long" name="Long Description">Test 123</div>

Javascript

$(function () {
    $('.summernote').summernote({
        toolbar: [
          ['headline', ['style']],
          ['style', ['bold', 'italic', 'underline', 'clear']],
          ['color', ['color']],
          ['font', ['strikethrough', 'superscript', 'subscript']],
          ['alignment', ['ul', 'ol', 'paragraph']],
          ['insert', ['link']],
        ],
        onblur: function() {
          var objid = $(this).attr("id");
          alert(objid);
        }
    });
});

Solution

  • Which version of summernote are you using?? If it's v0.6.5 or greater then use camel case i.e. onBlur and not onblur . Try this and check. Also post what error are you getting,if any. Also, callback function is missing. Check http://summernote.org/deep-dive/