I'm trying to require/ import select2 into the project but unsuccessfully.
Tried these two always getting $('#state').select2 is not a function. When I include select2 in standard <script> tag, everything works.
require('./bootstrap');
import 'select2';
$('#state').select2({
minimumResultsForSearch: -1
});
and
require('./bootstrap');
window.select2 = require('select2/dist/js/select2.min.js');
$('#state').select2({
minimumResultsForSearch: -1
});
If you are using laravel mix after you install select2 using npm
npm i select2
You can simply add it to your app.js
require('select2');
Or
window.select2 = require('select2');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With