How to recover the functions of a cloned editor?

0

I'mdynamicallyaddingthesummernotebelowingreen.I'mactuallycloningtheonesabove.OfcourseIwouldhaveaproblemwiththatotherwiseitwouldnotbeprogramming.Addedpublisherfunctionsdonotwork.CouldanyonetellmewhatIshoulddotogetaroundthisproblem?

I'musingthecodebelowtoaddit.

$(document).on('click','.adicionar',function(){varcontent=$("#perguntas_formatadas").html();
    $("#clone_perguntas_formatadas").append(content);
    $("#clone_perguntas_formatadas .form-group").attr("data-remove", 1);
});
    
asked by anonymous 03.08.2017 / 22:09

1 answer

0

I've never used Summernote, but seeing the API core documentation has the following functions to get the content typed (in HTML) and there is also how to define a content, inserting within an already existing Summernote, respectively:

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

So basically:

// Inicia o primeiro Summernote:
$('div#primeiro').summernote()
   .summernote('code', '<b>Esse</b> é o <u>primeiro</u> summernote');

// Excuta quando clicar em "Copiar":
$('#copiar').on('click', function() {

  // Copia o conteúdo do primeiro Summernote:
  CodigoDoPrimeiroSummerNote = $('div#primeiro').summernote('code');
  
  // Cria outros Summernote clonados do primeiro:
  $('<x-summernote></x-summernote>').appendTo('#clones');

  $('x-summernote').last().summernote()
    .summernote('code', CodigoDoPrimeiroSummerNote);

});
<!-- Bibliotecas externas (JQuery, Bootstrap, Summernote...): --><link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet"><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script><scriptsrc="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.6/summernote.css" rel="stylesheet"><script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.6/summernote.js"></script><divid="primeiro"></div>

<button id="copiar" class="btn">Copiar</button>

<div id="clones"></div>
    
03.08.2017 / 22:40