Dropping ember-select2 for custom component

Fixes #53
This commit is contained in:
Matthew Dillon 2015-11-13 15:13:46 -07:00
parent 024836cab0
commit d05c31cc94
8 changed files with 75 additions and 28 deletions

View file

@ -0,0 +1,35 @@
import Ember from 'ember';
const { Component } = Ember;
export default Component.extend({
tagName: 'select',
attributeBindings: [
'multiple',
],
options: null,
selected: null,
nameAttr: null,
change: function() {
this.attrs.update(this.$().select2('val'));
},
didInsertElement: function() {
if (this.get('placeholder')) {
this.$().select2({
placeholder: this.get('placeholder'),
});
} else {
this.$().select2();
}
},
didRender: function() {
Ember.run.schedule('afterRender', this, function() {
this.$().select2('val', this.get('selected'));
});
},
});

View file

@ -0,0 +1,3 @@
{{#each options as |option|}}
<option value={{option.id}}>{{get-property option nameAttr}}</option>
{{/each}}