【问题标题】:Binding child ember objects to handlebars class将子 ember 对象绑定到车把类
【发布时间】:2012-05-01 19:09:40
【问题描述】:

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

--从 Ember.TextField 扩展的文本框类

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)视图初始渲染后,类设置正确,但后续更改isInvalid值,通过onFocusOut调用,不要更改DOM中的类。想法?

【问题讨论】:

    标签: binding ember.js handlebars.js


    【解决方案1】:

    您不能将 view 块助手与 Ember.TextField 一起使用。

    【讨论】:

    • 我有同样的问题没有文本字段,我很确定这是一个错误或不打算工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多