Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember 1.0.0 input type radio 'checked' binding not updated when property changes

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?

like image 795
MrHus Avatar asked Mar 23 '23 07:03

MrHus


1 Answers

{{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!

like image 109
chopper Avatar answered Apr 27 '23 19:04

chopper