[BUG] `Uncaught TypeError: $(...).select2 is not a function` with `4.1.0-rc.0 `
See original GitHub issueI just wasted an hour because npm installed version 4.1.0-rc.0
. With 4.0.13
everything works as expected.
I’m using webpack and imported it with import 'select2'
When running
$('.select2').select2()
I get the error Uncaught TypeError: $(...).select2 is not a function
I’m not sure if it’s related to using webpack or because I’m using jQuery v3.6.0 (the release notes say The minimum jQuery version supported is the latest version in the 1.x, 2.x, and 3.x series
). But in either way it definitely should either work or output a better error message.
Additional Notes
I had to add the following webpack config (using laravel-mix) because I’m unfortunately have to use WordPress and jQuery is loaded via an own script tag, not included in the webpack bundle:
mix.webpackConfig({
externals: {
$: 'jQuery',
jquery: 'jQuery',
}
})
without this config select2 won’t attach to jQuery.fn
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (1 by maintainers)
Top GitHub Comments
This works:
or
and later
I use vite, it seems no versions can work.