// Wrap an optional error callback with a fallback error event.
var wrapError = function (model, options) {
var error = options.error;
options.error = function (model, resp, options) {
if (error) error(model, resp, options);
model.trigger('error', model, resp, options);
};
};
model.trigger(...) is expecting the model from wrapError arguments, but instead is model from options.error. We can see from ampersand-sync that the first argument is the response and not the model in this scenario:
// Make the request. The callback executes functions that are compatible
// With jQuery.ajax's syntax.
var request = options.xhr = xhr(ajaxSettings, function (err, resp, body) {
if (err && options.error) return options.error(resp, 'error', err.message);
the code in question:
model.trigger(...)
is expecting themodel
fromwrapError
arguments, but instead ismodel
fromoptions.error
. We can see from ampersand-sync that the first argument is the response and not the model in this scenario: