将子ember对象绑定到把手类

时间:2012-05-01 19:09:41

标签: binding ember.js handlebars.js

与ember.view对象的子对象存在绑定问题。代码如下:

- 从Ember.TextField扩展的Textbox类

App.TextBox = Ember.TextField.extend({
attributeBindings:['placeholder', 'autocorrect','autocapitalize'],
value:null,
isInvalid:true,
validate:function(){
    this.set('isInvalid', false);
    return false;
},
focusOut:function(event){
    this.validate();
}});

---使用App.Textbox的视图

App.ViewTextBox = Ember.View.extend({
name:"viewName",
label:"View Label",
input: App.TextBox.extend({
    placeholder:function(){
        return this.get('parentView').get('label');
    }.property('label').cacheable()
})});

- 带绑定的把手

{{#view App.ViewTextBox}}
{{label}}<br/>
{{#view input valueBinding="parentView.value"}}
   <div {{bindAttr class="isInvalid"}}></div> 
{{/view}}{{/view}}

问题是这样的: 1)在初始渲染视图之后,正确设置了类,但是通过onFocusOut调用对isInvalid值的后续更改不会更改DOM中的类。想法?

1 个答案:

答案 0 :(得分:1)

您不能在Ember.TextField中使用view块助手。

相关问题