Skip to content

Instantly share code, notes, and snippets.

@optikalefx
Last active January 4, 2018 03:23
Show Gist options
  • Save optikalefx/fb6dfa9295a7885bfc87ec53833ceea9 to your computer and use it in GitHub Desktop.
Save optikalefx/fb6dfa9295a7885bfc87ec53833ceea9 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
selectedItems: [],
items: [],
actions: {
handleChange(item, event) {
if (event.target.checked) {
this.get('selectedItems').push(item);
}
console.log(this.get('selectedItems'));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
selectedChartTypes: [],
chartTypeOptions: [
{
key: 'sales',
value: 'Sales'
},
{
key: 'inventory',
value: 'Inventory'
},
{
key: 'units',
value: 'Units'
}
],
thing: Ember.computed('[email protected]', function() {
console.log('computed');
return this.get('chartTypes');
})
});
{{log 'template' chartTypes}}
{{wb-checkbox-list
items=chartTypeOptions
label="value"
key="key"
selectedItems=selectedChartTypes
}}
{{#each items as |item|}}
<div class="checkbox-wrap">
<label>{{get item label}}</label>
<input
type="checkbox"
onchange={{action 'handleChange' item}}
>
</div>
{{/each}}
{
"version": "0.13.0",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment