Created
February 4, 2016 14:54
-
-
Save miguelcobain/2b4af724b5f61ba06cf4 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
var categories = [ | |
{ | |
id: 1, | |
title: 'category 1' | |
}, { | |
id: 2, | |
title: 'category 2' | |
}, { | |
id: 3, | |
title: 'category 3' | |
}]; | |
export default Ember.Controller.extend({ | |
categories: categories, | |
selectedCategories: Ember.K, | |
actions: { | |
selectedChanged(selected) { | |
this.set('selectedCategories', selected); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'li', | |
classNames: ['list-group-item'], | |
classNameBindings: ['isActive:active'], | |
isActive: false, | |
click() { | |
this.toggleProperty('isActive'); | |
this.get('selectedChanged')(this.get('isActive')); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'ul', | |
classNames: ['list-group'], | |
selected: Ember.A(), | |
actions: { | |
itemSelected(model, isSelected) { | |
let selected = this.get('selected'); | |
if (isSelected) { | |
selected.addObject(model); | |
} else { | |
selected.removeObject(model); | |
} | |
//test if `this.get('selectedChanged')` exists | |
//before invoking it | |
this.get('selectedChanged')(selected); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.active { | |
background-color: red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.5.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "beta", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js", | |
"ember-template-compiler": "beta" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment