Search code examples
jquerytwitter-bootstrapfunctionwysihtml5

How can I apply a function to wysihtml5 texteditor?


Like this my function is working fine:

 $(".textarea").on("change keyup paste", function (){
      console.log("something happens");
  });

But when I want to apply it to my wysihtml5 it does not work anymore..

$('.textarea').wysihtml5();
$(".textarea").on("change keyup paste", function (){
      console.log("something happens");
});

Solution

  • Working solution:

    $('.textarea').wysihtml5({
           events: {
               load: function() {
                   var some_wysi = $('.textarea').data('wysihtml5').editor;
                   $(some_wysi.composer.element).bind('keyup', function(){ 
                         console.log("something happens");
                   });
                }
           }
    });