Reputation: 113
Here's the jsfiddle showing what I'm trying to do: http://jsfiddle.net/jdivock/ymgwh/1/
On the main app I'm trying to bind input and select fields to show/hide depending on whether or not a checkbox is selected. Sounds easy right? I'm confused as to why this won't work. I can set a disabledBinding no problem, and isVisible seems to work just fine when it's hardcode, but if I bind it to a field in the model . . . no dice.
template:
<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)
Upvotes: 2
Views: 928
Reputation: 7458
You were almost there, you'd just made a small omission.
You've used a binding for disabled
but not for isVisible
.
{{view Ember.TextField disabledBinding=false isVisible=false}}
should be
{{view Ember.TextField disabledBinding=false isVisibleBinding=false}}
Upvotes: 1