Skip to content

Instantly share code, notes, and snippets.

@tcjr
Created July 19, 2017 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcjr/6c1c3f6520b4a297dbe6be720c655b81 to your computer and use it in GitHub Desktop.
Save tcjr/6c1c3f6520b4a297dbe6be720c655b81 to your computer and use it in GitHub Desktop.
select categories
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
optionData: Ember.computed(function() {
return [{
id:1, name:'Something'
}, {
id:2, name:'Something'
}, {
id:3, name:'Another Thing'
}]
}),
groupedOptionData: Ember.computed(function() {
return [{
groupName: 'Alpha Corp',
options: [{
id:1, name:'Something'
}, {
id:3, name:'Another Thing'
}]
}, {
groupName: 'Beta Inc',
options: [{
id:2, name:'Something'
}]
}]
}),
actions: {
ignored() {
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#power-select
options=optionData
allowClear=true
onchange=(action 'ignored')
searchField='name'
as |cat|
}}
{{cat.name}}
{{/power-select}}
<hr/>
{{#power-select
options=groupedOptionData
allowClear=true
onchange=(action 'ignored')
searchField='name'
as |cat|
}}
{{cat.name}}
{{/power-select}}
<br>
<br>
{{outlet}}
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-power-select": "1.8.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment