Skip to content

Instantly share code, notes, and snippets.

@blatyo
Created August 12, 2009 21:01
Show Gist options
  • Select an option

  • Save blatyo/166761 to your computer and use it in GitHub Desktop.

Select an option

Save blatyo/166761 to your computer and use it in GitHub Desktop.
InputOnChange = Class.create({
initialize: function(elementToWatch, functionToExecute, delay){
this.id = null;
this.functionToExecute = functionToExecute;
this.delay = delay;
elementToWatch.observe('keyup', this.onKeyUp.bindAsEventListener(this));
},
onKeyUp: function(event){
if(this.id){
window.clearTimeout(this.id);
}
this.id = this.functionToExecute.delay(this.delay, event);
}
});
new InputOnChange($('myinput'), myajaxfunction, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment