7

I have a model, let's call it "modelA", which has a nested "collectionX" of say "modelB".

  • modelA
    • collectionX (modelB)

When working with a modelB instance, I can easily access its siblings or its collection's meta data using this.collection.

How can I access attributes of the parent model (modelA)?

Community
  • 1
  • 1
srmark
  • 7,942
  • 13
  • 63
  • 74

2 Answers2

10

There is no default way to do this is backbone. Just add the modelA attribute to the collection and access it within modelB.

Julien
  • 9,216
  • 4
  • 37
  • 38
1

Beware that in some cases it does make sense to add a model to multiple collections. In such cases what would the parent be? Likewise, what would collection be? The last one to which the model was added, right?

Right now, backbone is not equipped to handle having a model belong to multiple collections--that is, having multiple parents.

Mario
  • 6,572
  • 3
  • 42
  • 74