Skip to content

Commit

Permalink
fix multiple select2 component (#5046)
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu authored and thelostone-mc committed Aug 20, 2019
1 parent 8c4bf97 commit c62aeb3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/assets/v2/js/vue-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ Vue.component('select2', {
props: [ 'options', 'value' ],
template: '#select2-template',
mounted: function() {
var vm = this;
let vm = this;

$(this.$el).select2({ data: this.options })
.val(this.value)
.trigger('change')
.on('change', function() {
vm.$emit('input', this.value);
vm.$emit('input', $(this).val());
});
},
watch: {
value: function(value) {
// update value
$(this.$el).val(value).trigger('change');
if ([...value].sort().join(',') !== [...$(this.$el).val()].sort().join(',')) {
$(this.$el).val(value).trigger('change');
}
},
options: function(options) {
// update options
$(this.$el).empty().select2({ data: options });
}
},
Expand Down

0 comments on commit c62aeb3

Please sign in to comment.