Search code examples
javascriptjquerysummernote

How to set editor's height and populate at the same time?


Sorry for this really simple question.

I can use this to set the initial height of the editor:

$('#content').summernote({height: 300,});

And i can use this to populate the editor:

$('#content').summernote('code',content);

I want to use both of them at the same time but i can't make it work. Simply using one after another doesn't work. And i don't know how to use them both in one line. For example this doesn't work:

$('#content').summernote('code',content,{height:300});

Please help. Thank you.


Solution

  • I don't think it's possible to initialize the editor with data in one instruction.

    If you want it on one line and not exactly one instruction you can do

    $('#content').summernote({height: 300}).summernote('code',content);
    

    Or you can simply put your content in the element before initializing the editor

    $('#content').html(content).summernote({height: 300});