|
@@ -4,31 +4,24 @@ taxonomy:
|
|
category: docs
|
|
category: docs
|
|
---
|
|
---
|
|
|
|
|
|
-This is a list of all the Select 2 configuration options.
|
|
|
|
|
|
+This is a list of all the Select2 configuration options.
|
|
|
|
|
|
-| Option | Type | Default | Description |
|
|
|
|
|
|
+| Option | Type | Default | Description |
|
|
| ------ | ---- | ------- | ----------- |
|
|
| ------ | ---- | ------- | ----------- |
|
|
-| `adaptContainerCssClass` | | | |
|
|
|
|
-| `adaptDropdownCssClass` | | | |
|
|
|
|
| `ajax` | object | `null` | Provides support for [ajax data sources](/data-sources/ajax). |
|
|
| `ajax` | object | `null` | Provides support for [ajax data sources](/data-sources/ajax). |
|
|
| `allowClear` | boolean | `false` | Provides support for [clearable selections](/selections#clearable-selections). |
|
|
| `allowClear` | boolean | `false` | Provides support for [clearable selections](/selections#clearable-selections). |
|
|
-| `amdBase` | string | `./` | See [Using Select2 with AMD or CommonJS loaders](/builds-and-modules#using-select2-with-amd-or-commonjs-loaders). |
|
|
|
|
| `amdLanguageBase` | string | `./i18n/` | See [Using Select2 with AMD or CommonJS loaders](/builds-and-modules#using-select2-with-amd-or-commonjs-loaders). |
|
|
| `amdLanguageBase` | string | `./i18n/` | See [Using Select2 with AMD or CommonJS loaders](/builds-and-modules#using-select2-with-amd-or-commonjs-loaders). |
|
|
| `closeOnSelect` | boolean | `true` | Controls whether the dropdown is [closed after a selection is made](/dropdown#forcing-the-dropdown-to-remain-open-after-selection). |
|
|
| `closeOnSelect` | boolean | `true` | Controls whether the dropdown is [closed after a selection is made](/dropdown#forcing-the-dropdown-to-remain-open-after-selection). |
|
|
-| `containerCss` | object | null | Adds custom CSS to the container. Expects key-value pairs: `{ 'css-property': 'value' }` |
|
|
|
|
-| `containerCssClass` | string | `''` | |
|
|
|
|
| `data` | array of objects | `null` | Allows rendering dropdown options from an [array](/data-sources/arrays). |
|
|
| `data` | array of objects | `null` | Allows rendering dropdown options from an [array](/data-sources/arrays). |
|
|
| `dataAdapter` | | `SelectAdapter` | Used to override the built-in [DataAdapter](/advanced/default-adapters/data). |
|
|
| `dataAdapter` | | `SelectAdapter` | Used to override the built-in [DataAdapter](/advanced/default-adapters/data). |
|
|
| `debug` | boolean | `false` | Enable debugging messages in the browser console. |
|
|
| `debug` | boolean | `false` | Enable debugging messages in the browser console. |
|
|
-| `dir` | | |
|
|
|
|
|
|
+| `dir` | string | `ltr` | Sets the [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) on the selection and dropdown containers to indicate the direction of the text. |
|
|
| `disabled` | boolean | `false` | When set to `true`, the select control will be disabled. |
|
|
| `disabled` | boolean | `false` | When set to `true`, the select control will be disabled. |
|
|
| `dropdownAdapter` | | `DropdownAdapter` | Used to override the built-in [DropdownAdapter](/advanced/default-adapters/dropdown) |
|
|
| `dropdownAdapter` | | `DropdownAdapter` | Used to override the built-in [DropdownAdapter](/advanced/default-adapters/dropdown) |
|
|
| `dropdownAutoWidth` | boolean | `false` | |
|
|
| `dropdownAutoWidth` | boolean | `false` | |
|
|
-| `dropdownCss` | object | null | Adds custom CSS to the dropdown. Expects key-value pairs: `{ 'css-property': 'value' }` |
|
|
|
|
-| `dropdownCssClass` | string | `''` | |
|
|
|
|
|
|
+| `dropdownCssClass` | string | `''` | Adds additional CSS classes to the dropdown container. The helper `:all:` can be used to add all CSS classes present on the original `<select>` element. |
|
|
| `dropdownParent` | jQuery selector or DOM node | `$(document.body)` | Allows you to [customize placement](/dropdown#dropdown-placement) of the dropdown. |
|
|
| `dropdownParent` | jQuery selector or DOM node | `$(document.body)` | Allows you to [customize placement](/dropdown#dropdown-placement) of the dropdown. |
|
|
| `escapeMarkup` | callback | `Utils.escapeMarkup` | Handles [automatic escaping of content rendered by custom templates](/dropdown#built-in-escaping). |
|
|
| `escapeMarkup` | callback | `Utils.escapeMarkup` | Handles [automatic escaping of content rendered by custom templates](/dropdown#built-in-escaping). |
|
|
-| `initSelection` | callback | | See [`initSelection`](/upgrading/migrating-from-35#removed-the-requirement-of-initselection). **This option was deprecated in Select2 v4.0, and will be removed in v4.1.** |
|
|
|
|
| `language` | string or object | `EnglishTranslation` | Specify the [language used for Select2 messages](/i18n#message-translations). |
|
|
| `language` | string or object | `EnglishTranslation` | Specify the [language used for Select2 messages](/i18n#message-translations). |
|
|
| `matcher` | A callback taking search `params` and the `data` object. | | Handles custom [search matching](/searching#customizing-how-results-are-matched). |
|
|
| `matcher` | A callback taking search `params` and the `data` object. | | Handles custom [search matching](/searching#customizing-how-results-are-matched). |
|
|
| `maximumInputLength` | integer | `0` | [Maximum number of characters](/searching#maximum-search-term-length) that may be provided for a search term. |
|
|
| `maximumInputLength` | integer | `0` | [Maximum number of characters](/searching#maximum-search-term-length) that may be provided for a search term. |
|
|
@@ -37,9 +30,9 @@ This is a list of all the Select 2 configuration options.
|
|
| `minimumResultsForSearch` | integer | `0` | The minimum number of results required to [display the search box](/searching#limiting-display-of-the-search-box-to-large-result-sets). |
|
|
| `minimumResultsForSearch` | integer | `0` | The minimum number of results required to [display the search box](/searching#limiting-display-of-the-search-box-to-large-result-sets). |
|
|
| `multiple` | boolean | `false` | This option enables multi-select (pillbox) mode. Select2 will automatically map the value of the `multiple` HTML attribute to this option during initialization. |
|
|
| `multiple` | boolean | `false` | This option enables multi-select (pillbox) mode. Select2 will automatically map the value of the `multiple` HTML attribute to this option during initialization. |
|
|
| `placeholder` | string or object | `null` | Specifies the [placeholder](/placeholders) for the control. |
|
|
| `placeholder` | string or object | `null` | Specifies the [placeholder](/placeholders) for the control. |
|
|
-| `query` | A function taking `params` (including a `callback`) | `Query` | **This option was deprecated in Select2 v4.0, and will be removed in v4.1.** |
|
|
|
|
| `resultsAdapter` | | `ResultsAdapter` | Used to override the built-in [ResultsAdapter](/advanced/default-adapters/results). |
|
|
| `resultsAdapter` | | `ResultsAdapter` | Used to override the built-in [ResultsAdapter](/advanced/default-adapters/results). |
|
|
| `selectionAdapter` | | `SingleSelection` or `MultipleSelection`, depending on the value of `multiple`. | Used to override the built-in [SelectionAdapter](/advanced/default-adapters/selection). |
|
|
| `selectionAdapter` | | `SingleSelection` or `MultipleSelection`, depending on the value of `multiple`. | Used to override the built-in [SelectionAdapter](/advanced/default-adapters/selection). |
|
|
|
|
+| `selectionCssClass` | string | `''` | Adds additional CSS classes to the selection container. The helper `:all:` can be used to add all CSS classes present on the original `<select>` element. |
|
|
| `selectOnClose` | boolean | `false` | Implements [automatic selection](/dropdown#automatic-selection) when the dropdown is closed. |
|
|
| `selectOnClose` | boolean | `false` | Implements [automatic selection](/dropdown#automatic-selection) when the dropdown is closed. |
|
|
| `sorter` | callback | | |
|
|
| `sorter` | callback | | |
|
|
| `tags` | boolean / array of objects | `false` | Used to enable [free text responses](/tagging). |
|
|
| `tags` | boolean / array of objects | `false` | Used to enable [free text responses](/tagging). |
|