Skip to content

Instantly share code, notes, and snippets.

@dylants
Created July 17, 2013 15:41
Show Gist options
  • Save dylants/6021757 to your computer and use it in GitHub Desktop.
Save dylants/6021757 to your computer and use it in GitHub Desktop.
Backbone sync success and failure
return Backbone.View.extend({
...
events: {
"click #submit-button": "submit"
},
initialize: function() {
this.model.on( "sync", this.syncSuccess, this );
this.model.on( "error", this.syncFailed, this );
},
...
submit: function(ev) {
...
this.model.save();
},
syncSuccess: function() {
// this method is called after the save is successful
...
},
syncFailed: function(model, response, options) {
// this method is called after the save failed
...
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment