SHARE
TWEET

Untitled

a guest Jun 15th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $j2(document).on("change", ".abre", function(evt){
  2.  
  3. var selection = document.getSelection('#m_summernote_1');
  4. //conta inicio da palavra selecionada
  5. var start5 = selection.anchorOffset;
  6. //conta final da palavra selecionada
  7. var finish5 = selection.focusOffset;
  8.  
  9. //texto que irá substituir a palavra seleciona
  10. var textot = $j2("#valor option:selected").val();
  11.  
  12. //texto completo do textarea
  13. var textoc = $j2('#m_summernote_1').val();
  14.  
  15. //aqui eu limpo o texto original , apagando a partir do ponto incicial start5 e finish5
  16. var delText = textoc.substr(0,start5)+''+textoc.substr(finish5);
  17.  
  18. // aqui coloco o texto que irá substituir a palavra selecionada
  19. var addText = textoc.substr(0,start5)+textot+delText.substr(start5);
  20.  
  21. //aqui eu substituo o texto do textarea
  22. $("#m_summernote_1").summernote("code", addText);
  23. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top