Open jackboberg opened 9 years ago
Hey @jackboberg!
Yeah, that doesn't look correct, good spot. It's sort of related to this https://github.com/AmpersandJS/ampersand-state/issues/92 too.
The reason this is happening is: when we initialize a parent model we:
{parent: true}
as the optionsSince parse: true
is ignored in a set()
and is only checked and run during initialize, the child model isn't being initialized properly.
I'm not totally sure of the best solution to this immediately, but we definitely need to fix it, as it will be affecting normal server returned results too.
Thanks for the feedback. Can you give any insight as to why parse: true
is ignored in a set()
? See also: [https://github.com/AmpersandJS/ampersand-state/issues/84]
@jackboberg it's legacy from backbone. They had some discussion about adding that behaviour but it never got merged: https://github.com/jashkenas/backbone/pull/2636/files.
On potential challenge I can see of adding it, is that the required parsing is arguably bound to the server representation of the data: i.e. a custom parse perhaps doesn't make sense in general - it's specifically to deal with data specifically formatted in some way by the server. Though, that argument isn't quite relevant to what we need here.
That makes sense, and I agree this is a bit of a tangent. But, I feel like since it defaults to false
allowing a user to explicitly do a .set(attrs, { parse: true })
only adds flexibility.
In my uses running parse
when it's not needed would not be harmful, just wasted effort. Are there examples where a 'good practice' use of parse
could be an issue if it was run unexpectedly?
Hey !
Is there a workaround for this ?
I tried your pull request but I get a Uncaught TypeError: Cannot read property 'xxx' of null
, it seems that attrs is not passed correctly to the parse method.
Thanks !
I just rebased (my PR was a bit out of date). The tests still pass, not sure why you would get that error.
I am not sure if this is expected behavior.