This commit is contained in:
Matthew Dillon 2015-11-12 15:43:44 -07:00
parent 9ed63ca5ba
commit dbcc51c80d
6 changed files with 69 additions and 19 deletions

View file

@ -0,0 +1,39 @@
import Ember from 'ember';
const { Component } = Ember;
export default Component.extend({
tagName: 'select',
value: null,
nameAttr: null,
listItems: null,
placeholder: null,
selected: null,
selectize: null,
attributeBindings: [
'multiple',
],
change: function() {
this.attrs["update"](this.get('selectize').getValue());
},
didReceiveAttrs: function() {
this._super(...arguments);
if (!this.attrs.update) {
throw new Error(`You must provide an \`update\` action.`);
}
},
didInsertElement: function() {
this.$().selectize({
plugins: ['drag_drop'],
items: this.get('selected'),
});
this.set('selectize', this.$()[0].selectize);
},
});

View file

@ -0,0 +1,6 @@
{{#if placeholder}}
<option value="">{{placeholder}}</option>
{{/if}}
{{#each listItems as |option|}}
<option value={{option.id}} selected={{equal option.id value.id}}>{{get-property option nameAttr}}</option>
{{/each}}