Initializing Select2 throws define undefined error

When I load a Release 4.0.0 candidate ( https://github.com/select2/select2/releases/tag/4.0.1-rc.1 ) into Select2 and use it, I get a JavaScript error: Uncaught ReferenceError: define is not defined .

Here I read that this is related to the AMD bootloader (which I do not use): https://groups.google.com/forum/#!topic/select2/PCQpiJxIIXQ

If I do not use jquery.select2.js from RC, but select2.min.js from the current master: https://raw.githubusercontent.com/select2/select2/master/dist/js/select2.min.js

it works!

But I'm curious that I'm forgetting here. Most likely I'm doing something wrong.

Edit - sample code:

in the head:

 <script language='Javascript' src='scripts/jquery-1.9.1.min.js'></script> <script language='Javascript' src='scripts/jquery.select2.js'></script> 

in body:

 <script type="text/javascript"> $(document).ready(function(){ $('#id_of_select').select2({ tags: "true", placeholder: "", allowClear: true, tokenSeparators: [',', ' '] }); }); </script> <select multiple id="id_of_select" name="name[]"> <option value="1" selected="">Option 1</option> <option value="2" selected="">Option 2</option> <option value="5">Option 3</option> </select> 
+7
javascript jquery jquery-select2-4
source share
1 answer

Well, this is bad for me .. there are several folders in the folder structure of select2 package, including:

  • dist
  • src

I used javascript from src folder. But it seems that the correct files are in the dist folder.

+10
source share

All Articles