This is probably beyond easy, but I'm having a hard time to figure out how to access properties of parent views:
App.ParentView = Ember.View.extend({
foo: 'bar',
child_view: Ember.View.extend({
init: function(){
// get the value of App.ParentView.foo
// ???
}
})
});
To get the view: this.get('parentView')
To get the value of foo this.get('parentView.foo')
In Ember before 1.0.pre you could also use getPath
method, instead of chains of get(), for more succinct (and generally safer) code:
this.getPath("parentView.foo");
What's cool in Ember 1.0.pre is that get()
method now supports paths, so you can write
this.get("parentView.foo");
Tom is correct. I also created a JS Fiddle to demonstrate this and also illustrate the special contentView
property, which can be useful in this type of situation: http://jsfiddle.net/rSLQK/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With