Checkin.
From what I can tell, the bottleneck is in selectize itself. Will drop this and work on select2.
This commit is contained in:
parent
6f15bc940d
commit
f0167c858d
3 changed files with 14 additions and 24 deletions
|
@ -17,41 +17,34 @@ export default Component.extend({
|
|||
],
|
||||
|
||||
change: function() {
|
||||
this.attrs["update"](this.get('selectize').getValue());
|
||||
this.attrs["update"](this.$()[0].selectize.getValue());
|
||||
},
|
||||
|
||||
didReceiveAttrs: function() {
|
||||
this._super(...arguments);
|
||||
console.log('didReceiveAttrs');
|
||||
|
||||
if (!this.attrs.update) {
|
||||
throw new Error(`You must provide an \`update\` action.`);
|
||||
}
|
||||
|
||||
Ember.run.schedule('actions', this, () => {
|
||||
console.log('before adding');
|
||||
this.$()[0].selectize.setValue(this.get('selected'), true);
|
||||
console.log('after adding')
|
||||
});
|
||||
},
|
||||
|
||||
didInsertElement: function() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.$().selectize({
|
||||
console.log('didInsertElement');
|
||||
const options = {
|
||||
closeAfterSelect: true,
|
||||
selectOnTab: true,
|
||||
plugins: ['drag_drop'],
|
||||
items: this.get('selected'),
|
||||
});
|
||||
|
||||
this.set('selectize', this.$()[0].selectize);
|
||||
},
|
||||
|
||||
didRender: function() {
|
||||
this._super(...arguments);
|
||||
|
||||
const selected = this.get('selected');
|
||||
if (!isEmpty(selected)) {
|
||||
this.get('selected').forEach((item) => {
|
||||
this.get('selectize').addItem(item, true);
|
||||
});
|
||||
} else {
|
||||
this.get('selectize').clear(true);
|
||||
}
|
||||
|
||||
this.$().selectize(options);
|
||||
},
|
||||
|
||||
});
|
||||
|
|
Reference in a new issue