最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Ember 1.0.0 input type radio 'checked' binding not updated when property changes - Stack Overflow

programmeradmin4浏览0评论

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 badges
Add a ment  | 

2 Answers 2

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"}}.

发布评论

评论列表(0)

  1. 暂无评论