Anthony Haffey Anthony Haffey - 14 days ago 8
Javascript Question

jquery trigger event when deleting in ACE editor

I'm using Ace editor on my website (which has so far been great!). I need to capture every moment some text on the editor changes. I have given the editor the id of "Ace_javascript_editor". When I use:

$("#Ace_javascript_editor").on("input",function(){
//code here
}


It fires whenever I add text to the editor, but NOT when I DELETE text in the editor. I haven't found an elegant solution to what seems like a simple problem. On "Keyup" and "keydown" don't work in Ace editor in my experience and from what I've read online.

Answer

use the input event from the editor instead of the one from the browser

var editor = ace.edit("#Ace_javascript_editor")
....
editor.on("input",function(){
  //code here
})