Skip to content

Instantly share code, notes, and snippets.

@blimmer
Forked from pwfisher/radio-button-component.js
Last active April 20, 2021 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blimmer/9d5e1b68ae58b6a5a2c9 to your computer and use it in GitHub Desktop.
Save blimmer/9d5e1b68ae58b6a5a2c9 to your computer and use it in GitHub Desktop.
# {{ radio-button name='dish' value='spam' groupValue=selectedDish }} Spam
# {{ radio-button name='dish' value='eggs' groupValue=selectedDish }} Eggs
#
App.RadioButtonComponent = Em.Component.extend
tagName: 'input'
type: 'radio'
attributeBindings: [ 'checked', 'name', 'type', 'value' ]
checked: Em.computed 'value', 'groupValue', ->
return @get('value') == @get('groupValue')
change: ->
@set('groupValue', @get('value'))
{{ radio-button name='thing' value='one' groupValue=selection }} One
{{ radio-button name='thing' value='two' groupValue=selection }} Two
Currently selected: {{ selection }}
@pwfisher
Copy link

Beautiful. Sadly, it sounds like it needs an oberserver? https://gist.github.com/vasilakisfil/d055d9d2d9b56f684b42#gistcomment-1769844

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment