Created
April 9, 2015 05:26
-
-
Save xypaul/1bfc92a7ca53442677bd to your computer and use it in GitHub Desktop.
Radio buttons - Ember
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Yes there is no template | |
App.RadioButtonComponent = Ember.Component.extend({ | |
tagName: 'input', | |
type: 'radio', | |
value: null, | |
attributeBindings: [ 'checked', 'name', 'type', 'value' ], | |
checked: function () { | |
return JSON.parse(JSON.stringify(this.get('value'))) == JSON.parse(JSON.stringify(this.get('groupValue'))); | |
}.property('value', 'groupValue').readOnly(), | |
change: function () { | |
this.set('groupValue', this.get('value')); | |
Ember.run.once(this, 'checked'); //manual observer | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#each option in s.d.field_options.options}} | |
{{radio-button name=uniqueRadioID value=option.label groupValue=s.record.Value}} {{option.label}} | |
{{/each}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably also needs a wrapper called radio-buttons, where you just give it an array of options and a value and it'll do everything, just like the dropdown component.