gitlab-org--gitlab-foss/app/assets/javascripts/vue_shared/components/select2_select.vue
Luke Bennett 642c7252d4
Move import projects karma specs to jest
Improvements to the stability/validity of the specs.
2019-04-25 19:59:44 +01:00

35 lines
620 B
Vue

<script>
import $ from 'jquery';
import 'select2';
export default {
name: 'Select2Select',
props: {
options: {
type: Object,
required: false,
default: () => ({}),
},
value: {
type: String,
required: false,
default: '',
},
},
mounted() {
$(this.$refs.dropdownInput)
.val(this.value)
.select2(this.options)
.on('change', event => this.$emit('input', event.target.value));
},
beforeDestroy() {
$(this.$refs.dropdownInput).select2('destroy');
},
};
</script>
<template>
<input ref="dropdownInput" type="hidden" />
</template>