Search code examples
jquerywysihtml5

Adding a new text in wysihtml5 editor at the cursor position


I have implemented a wysihtml5 editor in my project and in that editor I want to append certain text when I click on a dropdown. I used the combination on selection star method of jquery and setvalue method of wysihtml5 editor. But the text is appending always at the last .The JSFiddle is this.

[http://jsfiddle.net/nt11Lsg2/21/][1]

Thanks

le.net/nt11Lsg2/21/


Solution

  • You can try with this:

    var wysihtml5Editor = $('.textarea').data("wysihtml5").editor;
     wysihtml5Editor.composer.commands.exec("insertHTML", txtToAdd);