Bootstrap-multiselect: Uncaught TypeError: Cannot read property 'fn' of undefined

Created on 8 Mar 2019  路  6Comments  路  Source: davidstutz/bootstrap-multiselect

I'm having trouble initializing bootstrap-multiselect. I am using NPM, webpack and have made sure bootstrap-multiselect is loaded after jquery and bootstrap:

import $ from 'jquery';
window.jQuery = $;
window.$ = $;

import Rails from 'rails-ujs';
import Turbolinks from 'turbolinks';
Rails.start();
Turbolinks.start();

import 'bootstrap/dist/js/bootstrap';
import 'bootstrap-multiselect/dist/js/bootstrap-multiselect';

Would anyone have any thoughts?

All 6 comments

Sorry, not a problem relating to this library

@echan00 Can you please tell us how you solved the issue? Did you add something to webpack.config.js?

Hmm I don't remember anymore. Make sure your jquery and bootstrap versions are up to date?

I'm facing the same problem. I am using Rails6 + Webpacker. I was able to work around the problem by doing the following, but is there any other better way?

     } else {
         // Browser globals
-        factory(root.jQuery, root.ko);
+        factory(window.jQuery, root.ko);
     }
    }
})(this, function ($, ko) {

It seems that root is being passed this, but via webpack(er), it is an empty object.

It works fine.
imports-loader + wrapper option:

wrapper: 'window',

https://github.com/davidstutz/bootstrap-multiselect/issues/1123#issuecomment-731151754

  1. Use the imports-loader to configure this
    https://stackoverflow.com/questions/28969861/managing-jquery-plugin-dependency-in-webpack/28989476#28989476

Is this a problem with bootstrap-multiselect being legacy?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ingenierotecnico picture ingenierotecnico  路  7Comments

Jojoshua picture Jojoshua  路  8Comments

fitucated picture fitucated  路  6Comments

bartclaeys picture bartclaeys  路  3Comments

zeyabadar picture zeyabadar  路  5Comments