Skip to content

Instantly share code, notes, and snippets.

@bj-mcduck
Created July 28, 2015 18:50
Show Gist options
  • Save bj-mcduck/097f852f3d819be53afa to your computer and use it in GitHub Desktop.
Save bj-mcduck/097f852f3d819be53afa to your computer and use it in GitHub Desktop.
Simple Select
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'option',
attributeBindings: ['value', 'selected'],
label: null,
selected: Ember.computed('value', 'selection', function(){
console.log(this.get('value'));
console.log(this.get('selection'));
return this.get('value') === this.get('selection');
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
options: [
{label: 'All My Claims', value: ''},
{label: 'My Active Claims', value: 'true'},
{label: 'My Inactive Claims', value: 'false'}
],
selection: 'true',
actions: {
changeSelect(value){
console.log('woot', value);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{simple-select options=options changeSelect='changeSelect' selected=selected}}
<br>
<br>
{
"version": "0.4.0",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.5/ember.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.5/ember-data.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment