Ember 1.0.0 input type radio 'checked' binding does not update when properties change

I have a problem: I have 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 the HTML switch.

So, when "active" is "yes", it should be checked, otherwise it should not be checked. This works for me, however, when I do an action that sets the "active" property to "no" or "yes", the status of the checkboxes checked is not updated.

Here's bin: http://emberjs.jsbin.com/ohaSezo/3/edit .

When using the checkbox, I get the same results: http://emberjs.jsbin.com/OWILUru/3/edit

I can’t figure it out, I think it should work, any ideas?

+4
source share
2 answers

{{bind-attr}} does not work this way - it communicates in only one way. Here are some examples of how you will do 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 and Ramblings software developer .

EDIT: Updated link according to the comments of Steve H. - thanks!

+7
source

In addition to the answer to the chopper, I will fix the first jsBin example: http://jsbin.com/ziyililetogi/2/edit . You can use {{view Ember.RadioButton selectionBinding="car.active" value="true" name="car"}} .

0
source

All Articles