I've got a problem: I've got this property called 'active' on one of my models, it is either the string 'yes' or 'no', now I want to use this property to check a HTML radio button.
So when 'active' is 'yes' it should be checked otherwise it should not be checked. I've got this to work, however when I make an action that sets the 'active' property to 'no' or 'yes' the radio buttons checked status doesn't update.
Here's a bin: .
When using a checkbox I get the same results:
I can't make sense of it, I think this should work, any ideas?
I've got a problem: I've got this property called 'active' on one of my models, it is either the string 'yes' or 'no', now I want to use this property to check a HTML radio button.
So when 'active' is 'yes' it should be checked otherwise it should not be checked. I've got this to work, however when I make an action that sets the 'active' property to 'no' or 'yes' the radio buttons checked status doesn't update.
Here's a bin: http://emberjs.jsbin./ohaSezo/3/edit.
When using a checkbox I get the same results: http://emberjs.jsbin./OWILUru/3/edit
I can't make sense of it, I think this should work, any ideas?
Share Improve this question asked Sep 24, 2013 at 15:19 MrHusMrHus 33.4k6 gold badges33 silver badges31 bronze badges2 Answers
Reset to default 7{{bind-attr}}
doesn't work that way - it only binds one way. Here are some examples of how you'd go about this:
Use {{view Ember.Checkbox checkedBinding="car.active"}}
: jsBin example
Or use a custom implementation of Ember.RadioButton
- {{view Ember.RadioButton checkedBinding="car.active"}}
: jsFiddle example
Credit for Ember.RadioButton
: Thoughts & Ramblings of a Software Developer.
EDIT: Updated link as per Steve H.'s ment - thanks!
In addition to chopper's answer, I fix the first jsBin example : http://jsbin./ziyililetogi/2/edit.
You can use {{view Ember.RadioButton selectionBinding="car.active" value="true" name="car"}}
.