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

Direct Import of Select2 on the add license form

parent 50c5efba
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import select2 from 'select2/select2';
import { KNOWN_LICENSES } from '../constants'; import { KNOWN_LICENSES } from '../constants';
export default { export default {
...@@ -17,22 +18,18 @@ export default { ...@@ -17,22 +18,18 @@ export default {
}, },
}, },
mounted() { mounted() {
import(/* webpackChunkName: 'select2' */ 'select2/select2') $(this.$refs.dropdownInput)
.then(() => { .val(this.value)
$(this.$refs.dropdownInput) .select2({
.val(this.value) allowClear: true,
.select2({ placeholder: this.placeholder,
allowClear: true, createSearchChoice: term => ({ id: term, text: term }),
placeholder: this.placeholder, createSearchChoicePosition: 'bottom',
createSearchChoice: term => ({ id: term, text: term }), data: KNOWN_LICENSES.map(license => ({ id: license, text: license })),
createSearchChoicePosition: 'bottom',
data: KNOWN_LICENSES.map(license => ({ id: license, text: license })),
})
.on('change', e => {
this.$emit('input', e.target.value);
});
}) })
.catch(() => {}); .on('change', e => {
this.$emit('input', e.target.value);
});
}, },
beforeDestroy() { beforeDestroy() {
$(this.$refs.dropdownInput).select2('destroy'); $(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