parent
024836cab0
commit
d05c31cc94
8 changed files with 75 additions and 28 deletions
35
app/pods/components/x-select/component.js
Normal file
35
app/pods/components/x-select/component.js
Normal 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'));
|
||||
});
|
||||
},
|
||||
|
||||
});
|
3
app/pods/components/x-select/template.hbs
Normal file
3
app/pods/components/x-select/template.hbs
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{#each options as |option|}}
|
||||
<option value={{option.id}}>{{get-property option nameAttr}}</option>
|
||||
{{/each}}
|
Reference in a new issue