Search code examples
jqueryjquery-select2jquery-select2-4

select2 multi option select all box is giving a TypeError


I have a multi option select2 box and wanted to add the ability to select all options. I found the following example example link to js fiddle. However for me when I select the "select all" button nothing happens. When I look at the web console I see the following error shown below.

TypeError: a is undefined[Learn More] select2.min.js:1:31982 

This appears to be some sort of select2 API problem that is not working in my browser environment. Not sure how to resolve this

here is the file it is pointing to

// here is that line 1 from the file select2.min.js
/*! Select2 4.0.4 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c)

Solution

  • Problem was related to loading two different version of JQuery.

    I am using flask so I have a layout.html file that had both of these version of JQuery being loaded. After removing the bottom one the issue went away.

     <!-- Adding JQuery library  -->
       <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    
       <script src="static/vendor/jquery/jquery.min.js"></script>