Skip to content

Instantly share code, notes, and snippets.

@ericallam
Created February 8, 2012 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericallam/1772080 to your computer and use it in GitHub Desktop.
Save ericallam/1772080 to your computer and use it in GitHub Desktop.
debouncing save
var TodoItem = Backbone.Model.extend({
initialize: function(){
this.save = _.debounce(this.save, 500);
},
toggleStatus: function(){
if(this.get('status') == 'incomplete'){
this.set({'status': 'complete'});
}else{
this.set({'status': 'incomplete'});
}
this.save();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment