-
-
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
Collection.parse should be called in .add if options.parse is true #1407
Comments
Hi @davidmarble, thanks for pointing this out. While there is no explicit call to var Model = Backbone.Model.extend({
parse: function(resp) {
console.log('parse');
return resp;
}
});
var Collection = Backbone.Collection.extend({model: Model});
new Collection().reset([{id: 1}], {parse: true}); |
@braddunbar, yep, I get that I opened the issue because there's inconsistency in how The inconsistency is that 3 ways I can think of:
Developers can sort of work around these by calling |
Ah! I misunderstood. You mean that you should be able to do I haven't thought about it before, but it does seem inconsistent. |
I just came up against this issue too and assumed that passing parse: true to a collection in these ways should mean that parse on the collection will get executed. The problem is that this is executed when calling fetch, but when I initially load my page I am constructing collections with the same JSON and parse isn't called. I guess I'll have to call it manually until/if this is fixed. |
This should be working now on |
Fixes jashkenas#3636, jashkenas#2824. Reverts jashkenas#1407.
Fixes jashkenas#3636, jashkenas#2824. Reverts jashkenas#1407.
Fixes jashkenas#3636, jashkenas#2824. Reverts jashkenas#1407.
Fixes jashkenas#3636, jashkenas#2824. Reverts jashkenas#1407.
In the constructor of Collection (currently line 554 - https://github.com/documentcloud/backbone/blob/master/backbone.js#L554), the below line indicates that the
reset
method, oradd
method called byreset
, should checkoptions.parse
, and if if true, callparse
on the models passed in.However, there is no such logic in the
add
orreset
methods of Collection. Seems to be an oversight.The text was updated successfully, but these errors were encountered: