Created
April 3, 2019 17:06
-
-
Save ger86/da26303e8b438dfe0237b6f2d1e6542f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'select2/dist/js/select2.full.min.js'; | |
export default () => { | |
const $select2 = $('.select2'); | |
const autocompleteUrl = $select2.data('autocomplete-url'); | |
$select2.select2({ | |
ajax: { | |
url: autocompleteUrl, | |
data: params => ({ s: params.term}), | |
processResults: data => ({ results: data.map(d => ({id: d.id, text: d.name}))}) | |
}, | |
theme: 'bootstrap4' | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment