Skip to content

Instantly share code, notes, and snippets.

@ger86
Created April 3, 2019 17:06
Show Gist options
  • Save ger86/da26303e8b438dfe0237b6f2d1e6542f to your computer and use it in GitHub Desktop.
Save ger86/da26303e8b438dfe0237b6f2d1e6542f to your computer and use it in GitHub Desktop.
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