开发者

What's the best way to reset deeply nested collections?

I have the following data structure:

One ModelA has a nested collection of ModelBs.

Each ModelB has a nested collection of ModelCs

By overriding ModelA's par开发者_如何学编程se method, I can easily bootstrap the attributes for ModelA and populate the nested collection of ModelBs :

assuming the server sends { modelA_attributes: { ... }, arrayOfB_Attributes: [{..}, {..}, ..]} I can do in the parse method: modelA.nestedBs.reset arrayOfB_Attributes and return modelA_atrributes

The problem is how can I easily reset the attributes of all ModelCs for each ModelB ?


Have you considered using Backbone-Relational? It'll handle most of these. I found a race condition doing this kind of stuff a few weeks ago, but it looks like Paul's fixed it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜