Commit 0900a92a authored by Tim Zallmann's avatar Tim Zallmann

Direct Import of Select2 on the add license form

parent 50c5efba
<script>
import $ from 'jquery';
import select2 from 'select2/select2';
import { KNOWN_LICENSES } from '../constants';
export default {
......@@ -17,22 +18,18 @@ export default {
},
},
mounted() {
import(/* webpackChunkName: 'select2' */ 'select2/select2')
.then(() => {
$(this.$refs.dropdownInput)
.val(this.value)
.select2({
allowClear: true,
placeholder: this.placeholder,
createSearchChoice: term => ({ id: term, text: term }),
createSearchChoicePosition: 'bottom',
data: KNOWN_LICENSES.map(license => ({ id: license, text: license })),
})
.on('change', e => {
this.$emit('input', e.target.value);
});
$(this.$refs.dropdownInput)
.val(this.value)
.select2({
allowClear: true,
placeholder: this.placeholder,
createSearchChoice: term => ({ id: term, text: term }),
createSearchChoicePosition: 'bottom',
data: KNOWN_LICENSES.map(license => ({ id: license, text: license })),
})
.catch(() => {});
.on('change', e => {
this.$emit('input', e.target.value);
});
},
beforeDestroy() {
$(this.$refs.dropdownInput).select2('destroy');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment