Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Created August 13, 2013 13:49
Show Gist options
  • Save alexspeller/6221312 to your computer and use it in GitHub Desktop.
Save alexspeller/6221312 to your computer and use it in GitHub Desktop.
{{#each button in view.content}}
<label>
<input type="radio" {{bindAttr value="button.value"}} {{bindAttr name="view.groupName"}}/>
{{button.label}}
</label>
{{/each}}
App.RadioButtonGroup = Em.View.extend
templateName: 'radio_button_group'
classNames: ['radio-group']
groupName: (->
"radiogroup-#{Em.guidFor(@)}"
).property()
change: ->
@set 'value', @$('input:checked').val()
updateSelected: (->
@$("input[value=#{@get('value')}]")[0].checked = true
).observes 'value'
didInsertElement: -> @updateSelected()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment