Skip to content

Instantly share code, notes, and snippets.

@nathanhammond
Last active October 16, 2018 18:36
Show Gist options
  • Save nathanhammond/de2a8adcfcadd392cd1c8b86c4aadf90 to your computer and use it in GitHub Desktop.
Save nathanhammond/de2a8adcfcadd392cd1c8b86c4aadf90 to your computer and use it in GitHub Desktop.
Checked Binding
import Ember from 'ember';
export default Ember.Controller.extend({
radioValue: 'one',
display: Ember.computed('radioValue', function() {
return JSON.stringify(this.get('radioValue'));
}),
actions: {
modify(arg) {
this.set('radioValue', arg.target.value);
}
}
});
import Ember from 'ember';
export function eq(params) {
return params[0] === params[1];
}
export default Ember.Helper.helper(eq);
<label><input type="radio" name="thing" checked={{eq this.radioValue "one"}} onchange={{action "modify"}} value="one"> one</label>
<label><input type="radio" name="thing" checked={{eq this.radioValue "two"}} onchange={{action "modify"}} value="two">two</label>
<hr />
{{display}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment