Skip to content

Instantly share code, notes, and snippets.

@SaladFork
Last active May 26, 2016 21:23
Show Gist options
  • Save SaladFork/13e5dbf17b0026399ed44d20930b6d5c to your computer and use it in GitHub Desktop.
Save SaladFork/13e5dbf17b0026399ed44d20930b6d5c to your computer and use it in GitHub Desktop.
Slack w/ @villander
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
selectMe: function() {
this.get('selection').pushObject(this.get('itemId'));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
selection: Ember.computed(() => []),
colors: [
'red',
'green',
'blue'
],
_selectionDidChange: Ember.observer('selection.[]', function() {
console.log(this.get('selection'));
})
});
{{#each colors as |color|}}
{{checkbox-selection-item
itemId=color
selection=(mut selection)}}
{{/each}}
Selection:
<ul>
{{#each selection as |color|}}
<li>{{color}}</li>
{{/each}}
</ul>
<button {{action 'selectMe'}}>
Select {{itemId}}
</button>
{
"version": "0.8.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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment