-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Backbone.sync: inconsistent arguments to options.success
and options.error
#2003
Comments
Yes these inconsistencies are not ideal. I vote stick with the Backbone if (success) success(model, resp, options); ( |
This seems like a fine change to me since the @PaulUithol Is this for a custom |
I like @caseywebdev's change as well, keeping the model as the first argument for both the callbacks and the events would be much cleaner |
@braddunbar Yes, it is. I don't really have a preference for either resolution (although always having the related model would be nice), just noticed the discrepancy when we got some errors from an old plugin that expected |
Sounds good to me -- feel free to do a PR and merge the change. |
Coming right up. |
Fixed in #2005. |
Fix #2003 - success callback arguments.
How does one access the remaining error handler options with the code changes in #2005? Why doesn't complete have the same API as success and error? |
What options do you need to access? The xhr is stored in |
@kpdecker I realized after posting this that you are referring to the I hadn't considered this before, but I think it's alright that we pass it through. It's also documented that way. |
@braddunbar Under Zepto error can include additional data explaining the exact error if it was an issue above the HTTP stack in the AJAX stack ex:
Where type can be things like timeout, parsererror, and others. With the error handler that is in place now this error information is silently discarded and there is no way for us to access it short of zepto global ajax events which are not without their drawbacks. Regarding the complete handler, it seems like it should be consistent one way or the other with the other AJAX callbacks, either augment or do not augment the parameters with the data object. |
Regarding the extra Zepto argument, the previous implementation didn't provide the argument either, right? As for |
The previous implementation exposed the RAW Zepto endpoints, on a per-instance basis via sync:
Note that the On the complete side I think the question is one of "is this an api" or "is this internal code that they are mucking with". If the former I would argue for API consistency between the three cases that are provided. If the later then all of my arguments are kind of pointless as it's not safe to implement against anyway :) |
Using new arguments to "success" callback while keeping compatibility with Backbone 0.9.9 and older (ref: jashkenas/backbone#2003)
Using new arguments to "success" callback while keeping compatibility with Backbone 0.9.9 and older (ref: jashkenas/backbone#2003)
Having some issues with this in our app, related to 1f3f452 .
It seems inconsistent to me to call
options.success
with the original arguments passed to it by jQuery (resp, status, xhr
->success(resp, status, xhr)
), and to change the signature for the error callback (xhr, status, thrown
->error(model, xhr, options)
?Shouldn't one of these styles be chosen? Either preserve the jQuery call signature, or convert it to the same style as the model events?
The text was updated successfully, but these errors were encountered: