Skip to content

Instantly share code, notes, and snippets.

@lennyburdette
Created March 7, 2017 22:00
Show Gist options
  • Select an option

  • Save lennyburdette/a60a0bc8db0931220da32a69c41095b6 to your computer and use it in GitHub Desktop.

Select an option

Save lennyburdette/a60a0bc8db0931220da32a69c41095b6 to your computer and use it in GitHub Desktop.
sq-option-set
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
onChange(newValue) {
this.sendAction('valueChanges', newValue);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
someArray: Ember.computed(function() {
return "red orange yellow".w()
}),
currentValue: "red"
});
import Ember from 'ember';
export function eq([a, b]) {
return a === b;
}
export default Ember.Helper.helper(eq);
{{#sq-option-set options=someArray value=currentValue valueChanges=(action (mut currentValue)) as |option onChange|}}
<input type="radio" checked={{option.isSelected}} onchange={{action option.onChange}} /> {{option.label}}
<div {{action option.onChange}}>{{option.label}}</div>
{{/sq-option-set}}
{{currentValue}}
{{#each options as |option|}}
{{yield (hash
isSelected=(eq option value)
label=option
onChange=(action "onChange" option))}}
{{/each}}
{
"version": "0.11.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.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment