Reputation: 10087
This question shows how to get properties of parent views.
Is there a way to achieve the same with general Ember.Object
s. For example how does the child
access properties of App.Parent
:
App.Parent = Ember.Object.extend({
parentProperty: 'someValue',
child: App.Child.create()
});
App.Child = Ember.Object.extend({
init: function(){
// I don't know which is my parent object
// but I still want to access the value of `parentProperty`
// var parentProperty = ???
}
});
Upvotes: 3
Views: 2009
Reputation: 8389
I put together a jsfiddle demonstrating how to update a child object with a "parent" property. The basic idea is check for the presence of a child on creation of the parent, and watch in case the child changes.
Hopefully, it will help. Comment here is you have any questions.
Upvotes: 1
Reputation: 2388
Can you pass the parent in when you create the child?
App.Parent = Ember.Object.extend({
parentProperty: 'someValue',
child: App.Child.create({ parent: App.Parent })
})
Upvotes: 1