Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $j2(document).on("change", ".abre", function(evt){
- var selection = document.getSelection('#m_summernote_1');
- //conta inicio da palavra selecionada
- var start5 = selection.anchorOffset;
- //conta final da palavra selecionada
- var finish5 = selection.focusOffset;
- //texto que irá substituir a palavra seleciona
- var textot = $j2("#valor option:selected").val();
- //texto completo do textarea
- var textoc = $j2('#m_summernote_1').val();
- //aqui eu limpo o texto original , apagando a partir do ponto incicial start5 e finish5
- var delText = textoc.substr(0,start5)+''+textoc.substr(finish5);
- // aqui coloco o texto que irá substituir a palavra selecionada
- var addText = textoc.substr(0,start5)+textot+delText.substr(start5);
- //aqui eu substituo o texto do textarea
- $("#m_summernote_1").summernote("code", addText);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement