Skip to content

Instantly share code, notes, and snippets.

@joshsmith
Last active November 24, 2016 05:23
Show Gist options
  • Save joshsmith/c7e287e23bc7ad72928bcd68b0822f2c to your computer and use it in GitHub Desktop.
Save joshsmith/c7e287e23bc7ad72928bcd68b0822f2c to your computer and use it in GitHub Desktop.
Radio Buttons
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
model: function() {
return {
choices: [
'friend',
'foe'
]
};
},
actions: {
error: function(error) {
console.log(error.message);
},
changed: function(value) {
this.set('currentValue', value);
console.log('currentValue is: ' + value);
}
}
});
import Ember from 'ember';
export function isEqual(params) {
return params[0] === params[1];
}
export default Ember.Helper.helper(isEqual);
<form action="" onchange={{action "changed" value="target.value"}} >
<input type="radio"
name="sex"
selected={{is-equal currentValue "friend"}} value="friend" />
<input type="radio"
name="sex"
value="foe"
selected={{is-equal currentValue "foe"}} />
</form>
{{currentValue}}
{
"version": "0.10.6",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment