silvia zulinka
silvia zulinka

Reputation: 731

how to add attribute name in summernote click to edit

I want to add element attribute name in summernote click to edit

html :

<button id="edit" class="btn btn-primary" onclick="edit()" type="button">Edit 1</button>
<button id="save" class="btn btn-primary" onclick="save()" type="button">Save 2</button>
<div class="click2edit">click2edit</div>

javascript:

var edit = function() {
  $('.click2edit').summernote({focus: true});
};

var save = function() {
  var makrup = $('.click2edit').summernote('code');
  $('.click2edit').summernote('destroy');
};

doc : http://summernote.org/examples/#click-to-edit

Upvotes: 1

Views: 4090

Answers (3)

Rupesh Arora
Rupesh Arora

Reputation: 577

You can do like this. Just find the text area add the name attribute.Hope it work.

var edit = function() {
    $('.click2edit').summernote({focus: true});
    $('.note-editor.note-frame.panel.panel-default').find('textarea').attr('name','mytextarea');
};

Upvotes: 1

silvia zulinka
silvia zulinka

Reputation: 731

var edit = function() { 
  $('.click2edit').summernote({focus: true});
  $('.note-editor').find('textarea').attr('name','mytextarea');
};

Upvotes: 0

Mohit Tanwani
Mohit Tanwani

Reputation: 6628

I don't think you need anything fancy here.

Use attr() on summernote selector

$('.summernote').attr('name', 'content');

Here, I assume that $('.summernote') is selector of editor applied.

Example, shows how to get instance of editor

$("#id").on("summernote.init", function(e, layoutInfo) {
    // get $editor element 
    var $editor = layoutInfo.editor();

    // add id attribute in $editor element 
    $editor.attr('id', $(this).attr('id') + "-of-example");
}).summernote(
    // summernote options.. 
);

Upvotes: 0

Related Questions