开发者

How to "fetch" nested models and collections using backbone.js

开发者 https://www.devze.com 2023-03-07 16:36 出处:网络
I have a model which has 2 nested collections.What\'s 开发者_如何转开发the best way of automatically fetching those collections when I \"fetch\" the parent model?In Rails you can include the dependant

I have a model which has 2 nested collections. What's 开发者_如何转开发the best way of automatically fetching those collections when I "fetch" the parent model?


In Rails you can include the dependant objects in your JSON. I do not know the backend you are using, but this would save you a couple round trips:

{
  att1: val,
  col1: [{obj1: val}, {...}],
  col2: [{...}]
}

Otherwise, override the initialize of Model to create and fetch the 2 new dependent collections.

0

精彩评论

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