0
  1. Can one have nested models in backbone.js? Example: Model A has one of its attributes as Model B

  2. Can one store more then one model type in collection?

Nilesh Kale
  • 233
  • 1
  • 4
  • 12

1 Answers1

0

Yes you can store models in attributes (nesting models). The main thing to watch out for is that change events to the nested model or collection will not propagate to the outside model.

You could use different models in a collection, but the default create and add methods will only create one type of model if they are passed attributes rather than an explicit model. Also, saving and fetching will require you to specify the URL on each model you pass in for that to work. In general, I wouldn't recommend it.

Emery
  • 92
  • 1
  • 9
  • Thanks Emery - As far as possible I'm trying only to use nested models instead of storing more then one model type in one collections! It does look like a messy thing to do from what you said! – Nilesh Kale Jul 23 '12 at 09:46