Initial commit
This commit is contained in:
130
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/01.adapters-and-decorators/docs.md
vendored
Executable file
130
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/01.adapters-and-decorators/docs.md
vendored
Executable file
@ -0,0 +1,130 @@
|
||||
---
|
||||
title: Adapters and Decorators
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
Starting in version 4.0, Select2 uses the [Adapter pattern](https://en.wikipedia.org/wiki/Adapter_pattern) as a powerful means of extending its features and behavior.
|
||||
|
||||
Most of the built-in features, such as those described in the previous chapters, are implemented via one of the [built-in adapters](/advanced/default-adapters). You may further extend the functionality of Select2 by implementing your own adapters.
|
||||
|
||||
## Adapter interfaces
|
||||
|
||||
All custom adapters must implement the methods described by the `Adapter` interface.
|
||||
|
||||
In addition, adapters that override the default `selectionAdapter` and `dataAdapter` behavior must implement the additional methods described by the corresponding `SelectionAdapter` and `DataAdapter` interfaces.
|
||||
|
||||
### `Adapter`
|
||||
|
||||
All adapters must implement the `Adapter` interface, which Select2 uses to render DOM elements for the adapter and bind any internal events:
|
||||
|
||||
```
|
||||
// The basic HTML that should be rendered by Select2. A jQuery or DOM element
|
||||
// should be returned, which will automatically be placed by Select2 within the
|
||||
// DOM.
|
||||
//
|
||||
// @returns A jQuery or DOM element that contains any elements that must be
|
||||
// rendered by Select2.
|
||||
Adapter.render = function () {
|
||||
return $jq;
|
||||
};
|
||||
|
||||
// Bind to any Select2 or DOM events.
|
||||
//
|
||||
// @param container The Select2 object that is bound to the jQuery element. You
|
||||
// can listen to Select2 events with `on` and trigger Select2 events using the
|
||||
// `trigger` method.
|
||||
// @param $container The jQuery DOM node that all default adapters will be
|
||||
// rendered within.
|
||||
Adapter.bind = function (container, $container) { };
|
||||
|
||||
// Position the DOM element within the Select2 DOM container, or in another
|
||||
// place. This allows adapters to be located outside of the Select2 DOM,
|
||||
// such as at the end of the document or in a specific place within the Select2
|
||||
// DOM node.
|
||||
//
|
||||
// Note: This method is not called on data adapters.
|
||||
//
|
||||
// @param $rendered The rendered DOM element that was returned from the call to
|
||||
// `render`. This may have been modified by Select2, but the root element
|
||||
// will always be the same.
|
||||
// @param $defaultContainer The default container that Select2 will typically
|
||||
// place the rendered DOM element within. For most adapters, this is the
|
||||
// Select2 DOM element.
|
||||
Adapter.position = function ($rendered, $defaultContainer) { };
|
||||
|
||||
// Destroy any events or DOM elements that have been created.
|
||||
// This is called when `select2("destroy")` is called on an element.
|
||||
Adapter.destroy = function () { };
|
||||
```
|
||||
|
||||
### `SelectionAdapter`
|
||||
|
||||
The selection is what is shown to the user as a replacement of the standard `<select>` box. It controls the display of the selection option(s), as well anything else that needs to be embedded within the container, such as a search box.
|
||||
|
||||
Adapters that will be used to override the default `selectionAdapter` must implement the `update` method as well:
|
||||
|
||||
```
|
||||
// Update the selected data.
|
||||
//
|
||||
// @param data An array of data objects that have been generated by the data
|
||||
// adapter. If no objects should be selected, an empty array will be passed.
|
||||
//
|
||||
// Note: An array will always be passed into this method, even if Select2 is
|
||||
// attached to a source which only accepts a single selection.
|
||||
SelectionAdapter.update = function (data) { };
|
||||
```
|
||||
|
||||
### `DataAdapter`
|
||||
|
||||
The data set is what Select2 uses to generate the possible results that can be selected, as well as the currently selected results.
|
||||
|
||||
Adapters that will be used to override the default `dataAdapter` must implement the `current` and `query` methods as well:
|
||||
|
||||
```
|
||||
// Get the currently selected options. This is called when trying to get the
|
||||
// initial selection for Select2, as well as when Select2 needs to determine
|
||||
// what options within the results are selected.
|
||||
//
|
||||
// @param callback A function that should be called when the current selection
|
||||
// has been retrieved. The first parameter to the function should be an array
|
||||
// of data objects.
|
||||
DataAdapter.current = function (callback) {
|
||||
callback(currentData);
|
||||
}
|
||||
|
||||
// Get a set of options that are filtered based on the parameters that have
|
||||
// been passed on in.
|
||||
//
|
||||
// @param params An object containing any number of parameters that the query
|
||||
// could be affected by. Only the core parameters will be documented.
|
||||
// @param params.term A user-supplied term. This is typically the value of the
|
||||
// search box, if one exists, but can also be an empty string or null value.
|
||||
// @param params.page The specific page that should be loaded. This is typically
|
||||
// provided when working with remote data sets, which rely on pagination to
|
||||
// determine what objects should be displayed.
|
||||
// @param callback The function that should be called with the queried results.
|
||||
DataAdapter.query = function (params, callback) {
|
||||
callback(queryiedData);
|
||||
}
|
||||
```
|
||||
|
||||
## Decorators
|
||||
|
||||
Select2 uses [decorators](https://en.wikipedia.org/wiki/Decorator_pattern) to expose the functionality of adapters through its [configuration options](/configuration).
|
||||
|
||||
You can apply a decorator to an adapter using the `Utils.Decorate` method provided with Select2:
|
||||
|
||||
```
|
||||
$.fn.select2.amd.require(
|
||||
["select2/utils", "select2/selection/single", "select2/selection/placeholder"],
|
||||
function (Utils, SingleSelection, Placeholder) {
|
||||
var CustomSelectionAdapter = Utils.Decorate(SingleSelection, Placeholder);
|
||||
});
|
||||
```
|
||||
|
||||
>>> All core options that use decorators or adapters will clearly state it in the "Decorator" or "Adapter" part of the documentation. Decorators are typically only compatible with a specific type of adapter, so make sure to note what adapter is given.
|
||||
|
||||
## AMD Compatibility
|
||||
|
||||
You can find more information on how to integrate Select2 with your existing AMD-based project [here](/getting-started/builds-and-modules). Select2 automatically loads some modules when the adapters are being automatically constructed, so those who are using Select2 with a custom AMD build using their own system may need to specify the paths that are generated to the Select2 modules.
|
||||
39
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/01.selection/docs.md
vendored
Executable file
39
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/01.selection/docs.md
vendored
Executable file
@ -0,0 +1,39 @@
|
||||
---
|
||||
title: Selection
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
Select2 provides the `SingleSelection` and `MultipleSelection` adapters as default implementations of the `SelectionAdapter` for single- and multi-select controls, respectively. Both `SingleSelection` and `MultipleSelection` extend the base `BaseSelection` adapter.
|
||||
|
||||
The selection adapter can be overridden by assigning a custom adapter to the `selectionAdapter` configuration option.
|
||||
|
||||
`select2/selection`
|
||||
|
||||
## Decorators
|
||||
|
||||
### `Placeholder` and `HidePlaceholder`
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/selection/placeholder`
|
||||
`select2/dropdown/hidePlaceholder`
|
||||
|
||||
These decorators implement Select2's [placeholder](/placeholders) features.
|
||||
|
||||
|
||||
### `AllowClear`
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/selection/allowClear`
|
||||
|
||||
This decorator implements [clearable selections](/selections#clearable-selections) as exposed through the `allowClear` option.
|
||||
|
||||
### `EventRelay`
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/selection/eventRelay`
|
||||
|
||||
Select2 has an internal event system that is used to notify parts of the component that state has changed, as well as an adapter that allows some of these events to be relayed to the outside word.
|
||||
11
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/02.array/docs.md
vendored
Executable file
11
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/02.array/docs.md
vendored
Executable file
@ -0,0 +1,11 @@
|
||||
---
|
||||
title: Array
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
The `ArrayAdapter` implements support for creating results based on an [array of data objects](/data-sources/arrays).
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/data/array`
|
||||
11
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/03.ajax/docs.md
vendored
Executable file
11
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/03.ajax/docs.md
vendored
Executable file
@ -0,0 +1,11 @@
|
||||
---
|
||||
title: Ajax
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
The `AjaxAdapter` implements support for creating results [from remote data sources using AJAX requests](/data-sources/ajax).
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/data/ajax`
|
||||
68
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/04.data/docs.md
vendored
Executable file
68
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/04.data/docs.md
vendored
Executable file
@ -0,0 +1,68 @@
|
||||
---
|
||||
title: SelectAdapter
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
Select2 provides the `SelectAdapter` as a default implementation of the `DataAdapter` adapter. It extends `BaseAdapter`.
|
||||
|
||||
This adapter can be overridden by assigning a custom adapter to the `dataAdapter` configuration option.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
- `select2/data/base`
|
||||
- `select2/data/select`
|
||||
|
||||
## Decorators
|
||||
|
||||
### `Tags`
|
||||
|
||||
This decorator implements the [tagging](/tagging) feature.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/data/tags`
|
||||
|
||||
### `MinimumInputLength`
|
||||
|
||||
This decorator implements the [minimum search term length](/searching#minimum-search-term-length) feature as exposed through the `minimumInputLength` configuration option.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/data/minimumInputLength`
|
||||
|
||||
### `MaximumInputLength`
|
||||
|
||||
This decorator implements the [maximum search term length](/searching#maximum-search-term-length) feature as exposed through the `maximumInputLength` configuration option.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/data/maximumInputLength`
|
||||
|
||||
### `InitSelection`
|
||||
|
||||
This decorator provides backwards compatibility for the `initSelection` callback in version 3.5.
|
||||
|
||||
In the past, Select2 required an option called `initSelection` that was defined whenever a custom data source was being used, allowing for the initial selection for the component to be determined. This has been replaced by the `current` method on the data adapter.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/compat/initSelection"`
|
||||
|
||||
### `Query`
|
||||
|
||||
This decorator provides backwards compatibility for the `query` callback in version 3.5.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/compat/query`
|
||||
|
||||
### `InputData`
|
||||
|
||||
This decorator implements backwards compatibility with version 3.5's `<input type="hidden" >` elements.
|
||||
|
||||
In past versions of Select2, a `<select>` element could only be used with a limited subset of options. An `<input type="hidden" >` tag was required instead, which did not allow for a graceful fallback for users who did not have JavaScript enabled. Select2 now supports the `<select>` element for all options, so it is no longer required to use `<input />` elements with Select2.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/compat/inputData`
|
||||
23
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/05.results/docs.md
vendored
Executable file
23
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/05.results/docs.md
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
---
|
||||
title: Results
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
The `ResultsAdapter` controls the list of results that the user can select from.
|
||||
|
||||
The results adapter can be overridden by assigning a custom adapter to the `resultsAdapter` configuration option. While the results adapter does not define any additional methods that must be implemented, it makes extensive use of the Select2 event system for controlling the display of results and messages.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/results`
|
||||
|
||||
## Decorators
|
||||
|
||||
### `SelectOnClose`
|
||||
|
||||
This decorator implements [automatic selection](/dropdown#automatic-selection) of the highlighted option when the dropdown is closed.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/dropdown/selectOnClose`
|
||||
55
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/06.dropdown/docs.md
vendored
Executable file
55
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/06.dropdown/docs.md
vendored
Executable file
@ -0,0 +1,55 @@
|
||||
---
|
||||
title: Dropdown
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
The dropdown adapter defines the main container that the dropdown should be held in. Select2 allows you to change the way that the dropdown works, allowing you to do anything from attach it to a different location in the document or add a search box.
|
||||
|
||||
It is common for decorators to attach to the `render` and `position` methods to alter how the dropdown is altered and positioned.
|
||||
|
||||
This adapter can be overridden by assigning a custom adapter to the `dropdownAdapter` configuration option.
|
||||
|
||||
`select2/dropdown`
|
||||
|
||||
## Decorators
|
||||
|
||||
### `AttachBody`
|
||||
|
||||
This decorator implements the standard [`dropdownParent`](/dropdown#dropdown-placement) method of attaching the dropdown.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/dropdown/attachBody`
|
||||
|
||||
### `AttachContainer`
|
||||
|
||||
When this decorator is loaded, Select2 can place the dropdown directly after the selection container, so it will appear in the same location within the DOM as the rest of Select2.
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/dropdown/attachContainer`
|
||||
|
||||
>>>> **Check your build.** This module is only included in the [full builds](/getting-started/builds-and-modules) of Select2.
|
||||
|
||||
### `DropdownSearch`
|
||||
|
||||
This decorator implements the [search box that is displayed at the top of the dropdown](/searching).
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/dropdown/search`
|
||||
|
||||
### `MinimumResultsForSearch`
|
||||
|
||||
This decorator implements the [`minimumResultsForSearch` configuration option](/searching#limiting-display-of-the-search-box-to-large-result-sets).
|
||||
|
||||
**AMD Modules:**
|
||||
|
||||
`select2/dropdown/minimumResultsForSearch`
|
||||
|
||||
### `CloseOnSelect`
|
||||
|
||||
This decorator implements the [`closeOnSelect` configuration option](/dropdown#forcing-the-dropdown-to-remain-open-after-selection).
|
||||
|
||||
`select2/dropdown/closeOnSelect`
|
||||
7
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/docs.md
vendored
Executable file
7
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/02.default-adapters/docs.md
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Built-in adapters
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
This section describes the built-in adapters for Select2, as well as the decorators they use to expose their functionality.
|
||||
7
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/chapter.md
vendored
Executable file
7
public/assets/vendor/select2-4.1.0-rc.0/docs/pages/14.advanced/chapter.md
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Advanced
|
||||
taxonomy:
|
||||
category: docs
|
||||
---
|
||||
|
||||
# Advanced Features and Developer Guide
|
||||
Reference in New Issue
Block a user