Closed violet-athena closed 11 years ago
Ok, I found out where the problem is. By default the io's sync method will pass an empty callback for error and success. Is this normal Backbone behaviour, or should the sync function trigger events on the model in case no callbacks are passed?
You can use the same success/error callbacks that you'd use with the AJAX-based Backbone.sync:
model.save({
success: function () { ... },
error: function () { ... }
});
Since I don't know where else to ask:
How to capture the error events triggered from the server on the client? I have a middleware that makes several checks before writing content to the DB and returns errors if those checks fail, however, when I try to capture the errors on the client's collection nothing happens. I tried binding to "error", "backend:error", when this failed I tried binding listeners directly to the socket, but still no luck.
In essence when creating a new model I have absolutely no feedback from the server. I don't know if the model was created successfully, or if there was an error.
I can see, through chrome dev tools, that there was a frame containing the error message sent by the server, but without a proper event to capture and display it, it's useless.
Is there such an event? If not this is an oversight that should be fixed.