Closed kfrajtak closed 9 years ago
I believe itemB.collection.parent
should get you to model A. Lemme know if that works.
Sorry for getting back to you quite late. Yes, that works, but what is the real difference between itemB.parent
and itemB.collection.parent
? I thought the first one is cleaner (but I might be wrong).
Thanks for your reply anyway.
If a model is part of a collection then it will have that collection in its collection
attribute. The model's parent
attribute is for when a model has other models as children, outside of a collection setting.
Hi, it would be nice to automatically setting collection and collection items parent for models initialized from JSON data. I have a model A that has a collection of items B and I'd like to access a property of the model A in a view rendered for item B. Or maybe there's a way how to achieve this and if anybody can tell me how, that would be nice :) Thanks, Karel