Skip to content

Instantly share code, notes, and snippets.

@FGRibreau
Created March 17, 2011 18:30
Show Gist options
  • Save FGRibreau/874862 to your computer and use it in GitHub Desktop.
Save FGRibreau/874862 to your computer and use it in GitHub Desktop.
jQuery-debounceargs
var myFunction = function(dataArray){
// Do something with these data (ajax ?)
console.log('Debounced arguments:', dataArray);
}
var myDebouncedFunction = $.debounceargs(5000, myDebouncedFunction);
myDebouncedFunction({model:'post', action:'save', data:[1,2,3,4]});
myDebouncedFunction({model:'comment', action:'add', data:{text:'hello world', author:'anonymous'}});
// Wait 5secs and firebug/inspector should print something like this:
[[Object { model="post", action="save", data=}], [Object { model="comment", action="add", data=String}]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment