Skip to content

Instantly share code, notes, and snippets.

@biscuitvile
Created August 14, 2013 02:19
Show Gist options
  • Select an option

  • Save biscuitvile/6227495 to your computer and use it in GitHub Desktop.

Select an option

Save biscuitvile/6227495 to your computer and use it in GitHub Desktop.
Radio button implementation in Ember.js The checked radio button currently does not change is value appropriately when the switching from model to model. Gender is assumed to be a binary choice in cats for the purposes of a breakable toy.
<p>
<label>
{{ view CatWorld.RadioButton name="genderSelection"
contentBinding="controller.gender" selectionBinding="gender" value="Male" id="Male" }}
Male
<label>
<label>
{{ view CatWorld.RadioButton name="genderSelection"
contentBinding="controller.gender" selectionBinding="gender" value="Female" id="Female" }}
Female
<label>
</p>
CatWorld.RadioButton = Ember.View.extend
tagName: "input"
type: "radio"
attributeBindings: [ "name", "type", "value", "checked:checked" ]
click: ->
@set("controller.gender", @$().val())
checked: ( ->
@get("value") == @get('controller.gender')
).property()
modelChanged: ( ->
@rerender()
).observes('controller.model')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment