Skip to content

Instantly share code, notes, and snippets.

@vitch
Created October 12, 2016 18:26
Show Gist options
  • Save vitch/f2980ae1d49162f7a856a916ff4c5443 to your computer and use it in GitHub Desktop.
Save vitch/f2980ae1d49162f7a856a916ff4c5443 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
data: Ember.computed(function() {
return [
{ id: 1 },
{ id: 2, isSelected: true },
{ id: 3 }
];
}),
actions: {
onDone() {
alert(this.get('data').filterBy('isSelected').mapBy('id'));
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#each data as |item|}}
<label>
<input type="checkbox" checked={{item.isSelected}} onchange={{action (mut item.isSelected) value='target.checked'}}>
{{item.id}}
</label>
{{/each}}
<br>
<br>
<button {{action 'onDone'}}>Done!</button>
{
"version": "0.10.5",
"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.8.0",
"ember-data": "2.8.0",
"ember-template-compiler": "2.8.0",
"ember-testing": "2.8.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment