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.com/ohaSezo/3/edit.
When using a checkbox I get the same results: http://emberjs.jsbin.com/OWILUru/3/edit
I can't make sense of it, I think this should work, any ideas?
{{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 comment - thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With