Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapError model param is descoped by options.error model param #38

Closed
engenb opened this issue Feb 26, 2015 · 2 comments
Closed

wrapError model param is descoped by options.error model param #38

engenb opened this issue Feb 26, 2015 · 2 comments
Labels

Comments

@engenb
Copy link

engenb commented Feb 26, 2015

the code in question:

// 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);
@yocontra
Copy link

yocontra commented Mar 4, 2015

Also having this issue, causing errors every time a request has an error

@lukekarrys
Copy link
Contributor

CLosed by #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants