Search code examples
twitter-bootstraprequirejstypeerrorbootstrap-multiselect

Using bootstrap-multiselect with require.js


I want to use bootstrap-multiselect with require.js. I added the following lines to the shim:

shim: {
bootstrap : {
            deps: [ 'jquery', 'jquery_ui']
        },
bootstrap_multiselect: {
            deps:['jquery', 'jquery_ui', 'bootstrap'],
            exports: 'multiselect'
        }
}

This is not working. I am getting the following exception:

"TypeError: $(...) multiselect is not a function"

on the following line-

$('#SomeDiv').multiselect({

Does anyone know what to add in exports to make this work?

I also updated the bootstrap-multiselect file from this link: https://github.com/davidstutz/bootstrap-multiselect/pull/665/files

I feel I am doing something wrong in the shim file.


Solution

  • Managed to resolve this error after I changed

    define(['jquery'], function($){//multiselect js here}
    

    to

    define(['jquery', 'bootstrap_multiselect'], function($){//multiselect js here}