Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

backbone.js: How can I access the parent model of a nested collection?

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)?

like image 349
srmark Avatar asked May 11 '11 19:05

srmark


1 Answers

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

like image 137
Julien Avatar answered Oct 14 '22 07:10

Julien