Error handler in collection.fetch() is never called
asgeo1 opened this issue · 0 comments
asgeo1 commented
In Backbone.offline, if I make a call to refresh() to update my collection from the server, the error handler will not get called. (assuming an error did occur and it needed to be called)
collection.fetch({
success: function(){
console.log('success');
},
error: function(){
console.log('error');
}
});
Looking at the code, it's because the options object passed into fetch() is not passed along the chain. There a few functions like this in the code:
Sync.prototype.pull = function(options) {
var _this = this;
if (options == null) options = {};
return this.ajax('read', this.collection.items, {
success: function(response, status, xhr) {
var item, _i, _len;
_this.collection.destroyDiff(response);
for (_i = 0, _len = response.length; _i < _len; _i++) {
item = response[_i];
_this.pullItem(item);
}
if (options.success) return options.success();
}
});
};
where the options parameter is not passed into the ajax calls. Only a success handler is passed. Which means my error handler will never make it into the call to Backbone.ajaxSync | Backbone.sync, where it needs to be.