diff --git a/docs/_includes/options/core/amd-support.html b/docs/_includes/options/core/amd-support.html index 9dfd2759..faa23246 100644 --- a/docs/_includes/options/core/amd-support.html +++ b/docs/_includes/options/core/amd-support.html @@ -4,7 +4,7 @@
- Yes, Select2 should work with most AMD or CommonJS loaders without any issues. + Select2 should work with most AMD- or CommonJS-compliant module loaders, including RequireJS and almond. Select2 ships with a modified version of the UMD jQuery template that supports both CommonJS and AMD environments.
- Due to a bug in older versions of the r.js build tool, Select2 was sometimes placed before jQuery in then compiled build file. Because of this, Select2 will trigger an error because it won't be able to find or load jQuery. + Due to a bug in older versions of the r.js build tool, Select2 was sometimes placed before jQuery in then compiled build file. Because of this, Select2 will trigger an error because it won't be able to find or load jQuery.
- You can fix this issue by upgrading to a newer version of the r.js build tool. + By upgrading to version 2.1.18 or higher of the r.js build tool, you will be able to fix the issue. +
+ +dist
or src
?
+
+ Select2 internally uses AMD and the r.js build tool to build the files located in the dist
folder. These are built using the files in the src
folder, so you can just point your modules to the Select2 source and load in jquery.select2
or select2/core
when you want to use Select2. The files located in the dist
folder are also AMD-compatible, so you can point to that file if you want to load in all of the default Select2 modules.
camelCase
options be written?
+
+ HTML data attributes are case-insensitive, so any options which contain capital letters will be parsed as if they were all lowercase. Because Select2 has many options which are camelCase, where words are separated by uppercase letters, you must write these options out with dashes instead. So an option that would normally be called allowClear
should instead be defined as allow-clear
.
+
This means that if you declare your <select>
tag as...
+ Select2 will register itself as a jQuery function if you use any of the distribution builds, so you can call .select2()
on any jQuery element where you would like to initialize Select2.
+
+$('select').select2(); ++ +
+ You can optionally pass an object containing all of the options that you would like to initialize Select2 with. +
+ ++$('select').select2({ + placeholder: 'Select an option' +}); ++
+$.fn.select2.defaults.set("ajax--cache", false); ++
- You can reset the default options by calling + You can reset the default options to their initial values by calling