-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
error handling for failed ajax request with the Model/Collection functions #99
Comments
I like the first solution. It will be the most suitable for the current implementation and usage. I also like the second one but if we implement this we should add support for all other events. The third one looks strange because we are placing event handlers in the configuration which is a precedent for this configuration options. I vote for the first one. If you have any considerations for one of the others please share them. |
I agree with you. The first one is also my favorite, that's why it's the first :). I also like the second but to be consitent we should implement for all events and I think currently we have more important features/bugs for jsblocks. [edit: fixed typo] |
I agree. |
Can this be extended to provide a callback function regardless of response, and to fire on a This is because as jsBlocks currently stands, if I want to use Currently users resort to using other ajax implementations to create/delete/update records instead of the built in myCollection.read(function(data, XHR) {
// Similar to a jQuery AJAX call, the second parameter could be an XHR object so that the status code can be read giving an extra level of feedback
});
// seeing as one sync operation could include create/update/delete requests all at once, it makes sense to also include an event parameter, or some other way of letting the user know which operation was performed
myCollection.sync(function(e, data, XHR) {
var data = data || {success: false};
if (e.type = 'blocks.delete' && data.success == true) {
// render success message by updating an alerts property in the view or similar
self.alerts.push('Successfully Deleted')
}
}); |
I think jsblocks should provide an api for the user for handling failed request.
I see some possible ways to register such a handler:
The often in nodejs used way:
Or the event way:
Or when creating the Model/Collection:
What do you think ?
The text was updated successfully, but these errors were encountered: