Skip to content

Instantly share code, notes, and snippets.

@e00dan
Created July 18, 2016 14:31
Show Gist options
  • Save e00dan/aca33e3c0f8db58e3b36021d40ed4439 to your computer and use it in GitHub Desktop.
Save e00dan/aca33e3c0f8db58e3b36021d40ed4439 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'input',
type: 'radio',
attributeBindings: ['type', 'htmlChecked:checked', 'value', 'name', 'disabled'],
htmlChecked: function() {
return this.get('value') === this.get('checked');
}.property('value', 'checked'),
change: function() {
this.set('checked', this.get('value'));
},
_updateElementValue: function() {
Ember.run.next(this, function() {
this.$().prop('checked', this.get('htmlChecked'));
});
}.observes('htmlChecked')
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
whichChoice: Ember.observer('choice', function() {
const choice = this.get('choice');
console.log('Choice is: ', choice);
})
});
Yes{{radio-button value='yes' checked=choice}}
No{{radio-button value='no' checked=choice}}
{
"version": "0.10.1",
"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.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment