How select2/select2 works
Select2 is a jQuery plugin that upgrades native select controls into searchable single- or multi-select interfaces. The user-facing path begins with the plugin creating a Select2 instance; users search or browse results, select items, and the control reflects the selection. Data can come from native options, JavaScript arrays, or remote AJAX, with tagging and paginated loading as important extensions. The graph preserves documented capabilities and major core modules; several internal connections are dashed because their wiring is not shown in the excerpts.
Main entry points: core.js Select2 Core · base.js Data Adapter · jquery.select2.js jQuery Plugin · search.js Dropdown Search
Components 21
Plugin and Core
- jQuery Plugin
src/js/jquery.select2.js - Select2 Core
src/js/select2/core.js - Defaults
src/js/select2/defaults.js - Option Parsing
src/js/select2/options.js
Data and Search
- Data Adapter
src/js/select2/data/base.js - Native Select Data
src/js/select2/data/select.js - Array Data
src/js/select2/data/array.js - Remote AJAX
src/js/select2/data/ajax.js - Tags and Tokens
src/js/select2/data/tags.js - Search Limits
src/js/select2/data/minimumInputLength.js
Selection and Results
- Selection Views
src/js/select2/selection/multiple.js - Inline Search
src/js/select2/selection/search.js - Dropdown Views
src/js/select2/dropdown.js - Dropdown Search
src/js/select2/dropdown/search.js - Results List
src/js/select2/results.js
Extensions and Localization
- Infinite Scroll
src/js/select2/dropdown/infiniteScroll.js - Body Attachment
src/js/select2/dropdown/attachBody.js - Diacritic Mapping
src/js/select2/diacritics.js - Translations
src/js/select2/translation.js - Language Catalog
src/js/select2/i18n
Other components
- Page User
Connections 21
- Page User → jQuery Plugin: invokes
- jQuery Plugin → Select2 Core: creates instance
src/js/jquery.select2.js - jQuery Plugin → Defaults: exposes defaults
src/js/jquery.select2.js - Select2 Core → Option Parsing: configures
- Select2 Core → Data Adapter: queries data
- Data Adapter → Native Select Data: uses native
- Data Adapter → Array Data: uses arrays
- Data Adapter → Remote AJAX: uses remote
- Inline Search → Select2 Core: emits query
src/js/select2/selection/search.js - Dropdown Search → Select2 Core: emits query
src/js/select2/dropdown/search.js - Select2 Core → Selection Views: updates selection
- Select2 Core → Dropdown Views: opens dropdown
- Select2 Core → Results List: updates results
- Tags and Tokens → Data Adapter: decorates data
- Search Limits → Data Adapter: limits queries
- Infinite Scroll → Remote AJAX: loads pages
- Dropdown Views → Body Attachment: attaches to body
- Dropdown Search → Results List: searches results
- Select2 Core → Translations: configures language
- Translations → Language Catalog: loads catalog
- Data Adapter → Diacritic Mapping: matches text