I'm trying to bind a Ember.TextField
's value
to a property in it's parent view.
This code worked prior to upgrading to the latest version of ember. I've read about the new view scoping but can't figure out if/how that applies here.
Template my-template
:
Input: {{view Ember.TextField valueBinding="theValue" }}
View:
App.MyView = Em.View.extend({
templateName: 'my-template',
theValue: null,
init: function(){
this._super();
this.set('theValue','');
},
keyDown: function(e){
if(e.keyCode === 13){
alert(this.get('theValue'));
}
}
});
jsFiddle: demo
I've tried "parentView.theValue"
and "view.parentView.theValue"
I know I can give the TextField
a viewName
and bind to that from inside MyView
but I want to know why the previous method stopped working.
Update:
I've updated your jsFiddle to work: http://jsfiddle.net/U3thg/23/
I just changed your valueBinding
to "view.theValue"
.
{{view Ember.TextField valueBinding="view.theValue" }}
To give you an answer of why the previous method stopped working. I think the ember's team changed the bound context in the templates. Now I think the current context is the controller attached to the enclosing view.
I derived the @ebryn fiddle:
http://jsfiddle.net/Sly7/tcvhB/
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