One simplification step further...

This commit is contained in:
Casey Foster
2013-01-31 06:47:11 -08:00
parent a60a96168a
commit 50201bea86

View File

@@ -427,7 +427,7 @@
if (success) success(model, resp, options);
model.trigger('sync', model, resp, options);
};
options.error = wrapError(this, options);
wrapError(this, options);
return this.sync('read', this, options);
},
@@ -474,7 +474,7 @@
if (success) success(model, resp, options);
model.trigger('sync', model, resp, options);
};
options.error = wrapError(this, options);
wrapError(this, options);
method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update');
if (method === 'patch') options.attrs = attrs;
@@ -508,7 +508,7 @@
options.success();
return false;
}
options.error = wrapError(this, options);
wrapError(this, options);
var xhr = this.sync('delete', this, options);
if (!options.wait) destroy();
@@ -830,7 +830,7 @@
if (success) success(collection, resp, options);
collection.trigger('sync', collection, resp, options);
};
options.error = wrapError(this, options);
wrapError(this, options);
return this.sync('read', this, options);
},
@@ -1503,7 +1503,7 @@
// Wrap an optional error callback with a fallback error event.
var wrapError = function (model, options) {
var error = options.error;
return function(resp) {
options.error = function(resp) {
if (error) error(model, resp, options);
model.trigger('error', model, resp, options);
};