这是显示我正在尝试做的事情的 jsfiddle:http: //jsfiddle.net/jdivock/ymgwh/1/
在主应用程序上,我正在尝试绑定输入并选择要显示/隐藏的字段,具体取决于是否选中了复选框。听起来很容易对吧?我很困惑为什么这不起作用。我可以设置 disabledBinding 没问题,并且 isVisible 在硬编码时似乎工作得很好,但是如果我将它绑定到模型中的字段。. . 没有骰子。
模板:
<script type="text/x-handlebars">
<ul>
{{#each App.people}}
<li>{{name}}<br/> disabled: {{disabled}} <br/>visible: {{visible}}<br/> {{view Ember.TextField disabledBinding="disabled" isVisible="visible"}}<br/><br/></li>
{{/each}}
<li>Hardcoded isVisible to false - <br/>{{view Ember.TextField disabledBinding=false isVisible=false}}</li>
</ul>
</script>
js:
window.App = Ember.Application.create();
App.adapter = DS.Adapter.create();
App.store = DS.Store.create({revision: 3, adapter: App.adapter});
App.Person = DS.Model.extend({
id: DS.attr('number'),
name: DS.attr('string'),
visible: DS.attr('boolean'),
disabled: DS.attr('boolean')
})
App.person1 = App.store.createRecord(App.Person, {id: 1, name: 'Disabled', disabled: true, visible: true})
App.person2 = App.store.createRecord(App.Person, {id: 2, name: 'Hidden (supposed to be)', disabled: false, visible: false})
App.person3 = App.store.createRecord(App.Person, {id: 3, name: 'Normal', disabled: false, visible: true})
App.people = App.store.findAll(App.Person)