Closed Pindar closed 11 years ago
This is up to your parse
function.
parse: (resp, options) {
if (options.xhr.status === 204) return this.attributes;
return resp;
}
Or however you want to deal with it.
It seems like a valid usecase for Backbone to handle this correctly (it already handles 500 error codes differently, for example)
Wouldn't the handling of status codes be a jQuery issue? @Pindar - where are you running into the error, and what version of Backbone and jQuery are you using?
@caseywebdev: your suggestion should be working, but I also agree with @philfreo that this could be a backbone task.
@tgriesser It's in the save function (line 464, https://github.com/documentcloud/backbone/blob/master/backbone.js#L464). The set function tries to set an empty string and therefore it returns false. I will write a little test in the next days. jQuery works right at this point because it calls the success callback. I think that either backbone should handle this special case or the user have to copy all attributes like in @caseywebdev suggestion.
jQuery: 1.8.3 backbone: 0.9.9
@Pindar this should be taken care of by #2024 - let me know if that works for you. Thanks for pointing out this issue!
@tgriesser Thx for the change! I tried to test it with the new master version (a93ed0443f) but now I have some trouble with other changes: #2064 . Maybe you can answer my new question?
@tgriesser I finally tested your changes and it works for me. Thx!
.fetch({success: testSuccess})
and
testSuccess: function(collection, response) {
console.log(response) // => null
}
This happens when the response is 204. This seems like something is really wrong. Should I open a ticket?
I don't get the problem:
The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields. http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
When you get the response from a 400 error code in the error callback, it is an object with a status
key. I expected the same.
I recognized that currently backbone.js tries to update the model also in case of no content (http status code 204). So the validation and all update functions will be called but without data it finally returns an error.
Is this behavior desired or should backbone recognize the special status code?