-
-
Save JesseObrien/5249176 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Overriding sync | |
var Sync = Backbone.sync; | |
Backbone.sync = function (method, model, options) { | |
var success = options.success; | |
var error = options.error; | |
// Your custom code goes here, you should be able to access | |
// the xhr via options.xhr, or in the second argument from the ajax call. | |
options.success = function (resp, status, xhr) { | |
success.apply(this, arguments); | |
alert("Success with model " + JSON.stringify(model)); | |
}; | |
options.error = function (xhr, status, error) { | |
error.apply(this, arguments); | |
alert("Error with model " + JSON.stringify(model)); | |
}; | |
return Sync.call(this, method, model, options); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment