From 11cd18bd93b90ea05a1490f4f66892676a5d9a72 Mon Sep 17 00:00:00 2001
From: Eric Dahl
-
In order to take advantage of custom data loading Select2 should be attached to an input type='hidden'
tag, otherwise data is parsed from select
's option
tags.
In order to take advantage of custom data loading Select2 should be attached to an input type='hidden'
tag, otherwise data is parsed from select
's option
tags.
Note that the separators are defined in the tokenSeparators option.
+Note that the separators are defined in the tokenSeparators option.
Note that this example uses the built in tokenizer function, but a custom one can be provided in the options.
option
element we are trying to match. Only given when attached to select
.
- Can be used to match against custom attributes on the option
tag in addition to matching on the option
's text.option
tag in addition to matching on the option
's text.
true
if search term matches the text, or false
otherwise.undefined
or null
is returned the
- input of the search field is unchanged.tokenSeparators
and createSearchChoice
@@ -1441,9 +1441,9 @@ $("#select").select2({
result
object. The result object:
Parameter | Type | Description |
---|---|---|
result.results | [object] | Array of result objects. The default renderers expect objects with id and text keys. The id attribute is required, even if custom renderers are used. The object may also contain a children key if hierarchical data is displayed. The object may also contain a disabled boolean property indicating whether this result can be selected. |
result.results | [object] | Array of result objects. The default renderers expect objects with id and text keys. The id attribute is required, even if custom renderers are used. The object may also contain a children key if hierarchical data is displayed. The object may also contain a disabled boolean property indicating whether this result can be selected. |
result.more | boolean | true if more results are available for the current search term. |
results.context | object | A user-defined object that should be made available as the context parameter to the query function on subsequent queries to load more result pages for the same search term. See the description of options.context parameter. |
results.context | object | A user-defined object that should be made available as the context parameter to the query function on subsequent queries to load more result pages for the same search term. See the description of options.context parameter. |
Gets or sets the selection. If the value
parameter is not specified, the id
attribute of the currently selected element is returned. If the value
parameter is specified it will become the current selection.
Gets or sets the selection. If the value
parameter is not specified, the id
attribute of the currently selected element is returned. If the value
parameter is specified it will become the current selection.
Parameter | Type | Description | @@ -1626,7 +1626,7 @@ $("#select").select2({
---|
change
event should be triggered. false
by default.change
event should be triggered. false
by default.val
method invoked on a single-select with an unset value will return ""
, while a val
method invoked on an empty multi-select will return []
.
Fired before the dropdown is shown.
The event listener can prevent the opening by calling preventDefault()
on the supplied event object.
Fired after the dropdown is shown.
-Fired when a choice is highlighted in the dropdown.
-The event object contains the following custom properties:
Fired when a choice is being selected in the dropdown, but before any modification has been made to the selection.
This event is used to allow the user to reject selection by calling event.preventDefault()
The event object contains the following custom properties:
Fired when a choice is being cleared in the dropdown, but before any modification has been made to the selection.
This event is used to allow the user to reject the clear by calling event.preventDefault()
For the clear button to be visible the allowClear
option needs to be true
.
Fired when a choice is about to be removed in the dropdown/input, but before any removal of the choice has been made.
This event is used to allow the user to reject removal by calling event.preventDefault()
The event object contains the following custom properties:
Fired when a choice is removed or cleared.
-The event object contains the following custom properties:
Fired when query function is done loading the data and the results list has been updated
-The event object contains the following custom properties:
-
In order to take advantage of custom data loading Select2 should be attached to an input type='hidden'
tag, otherwise data is parsed from select
's option
tags.
In order to take advantage of custom data loading Select2 should be attached to an input type='hidden'
tag, otherwise data is parsed from select
's option
tags.
result
object. The result object:
Parameter | Type | Description |
---|---|---|
result.results | [object] | Array of result objects. The default renderers expect objects with id and text keys. The id attribute is required, even if custom renderers are used. |
result.results | [object] | Array of result objects. The default renderers expect objects with id and text keys. The id attribute is required, even if custom renderers are used. |
result.more | boolean | true if more results are available for the current search term |
results.context | object | A user-defined object that should be made available as the context parameter to the query function on subsequent queries to load more result pages for the same search term. See the description of options.context parameter. |
results.context | object | A user-defined object that should be made available as the context parameter to the query function on subsequent queries to load more result pages for the same search term. See the description of options.context parameter. |
Gets or sets the selection. If the value
parameter is not specified, the id
attribute of the currently selected element is returned. If the value
parameter is specified it will become the current selection.
Gets or sets the selection. If the value
parameter is not specified, the id
attribute of the currently selected element is returned. If the value
parameter is specified it will become the current selection.
Parameter | Type | Description | diff --git a/select2-latest.html b/select2-latest.html index 2ef7223b..8ca9608f 100644 --- a/select2-latest.html +++ b/select2-latest.html @@ -500,7 +500,7 @@ function format(state) {||||||
---|---|---|---|---|---|---|---|---|
text | string | text of the option being matched. | ||||||
option | jquery object | the option element we are trying to match. Only given when attached to select .
- Can be used to match against custom attributes on the option tag in addition to matching on the option 's text. | ||||||
<returns> | boolean | true if search term matches the text, or false otherwise. |
undefined
or null
is returned the
- input of the search field is unchanged.tokenSeparators
and createSearchChoice
@@ -1496,9 +1496,9 @@ $("#select").select2({
result
object. The result object:
Parameter | Type | Description |
---|---|---|
result.results | [object] | Array of result objects. The default renderers expect objects with id and text keys. The id property is required, even if custom renderers are used. The object may also contain a children key if hierarchical data is displayed. The object may also contain a disabled boolean property indicating whether this result can be selected. |
result.results | [object] | Array of result objects. The default renderers expect objects with id and text keys. The id property is required, even if custom renderers are used. The object may also contain a children key if hierarchical data is displayed. The object may also contain a disabled boolean property indicating whether this result can be selected. |
result.more | boolean | true if more results are available for the current search term. |
results.context | object | A user-defined object that should be made available as the context parameter to the query function on subsequent queries to load more result pages for the same search term. See the description of options.context parameter. |
results.context | object | A user-defined object that should be made available as the context parameter to the query function on subsequent queries to load more result pages for the same search term. See the description of options.context parameter. |
Gets or sets the selection. If the value
parameter is not specified, the id
attribute of the currently selected element is returned. If the value
parameter is specified it will become the current selection.
Gets or sets the selection. If the value
parameter is not specified, the id
attribute of the currently selected element is returned. If the value
parameter is specified it will become the current selection.
Parameter | Type | Description | @@ -1713,7 +1713,7 @@ $("#e1").select2({
---|
change
event should be triggered. false
by default.change
event should be triggered. false
by default.val
method invoked on a single-select with an unset value will return ""
, while a val
method invoked on an empty multi-select will return []
.
Fired before the dropdown is shown.
The event listener can prevent the opening by calling preventDefault()
on the supplied event object.
Fired after the dropdown is shown.
-Fired when a choice is highlighted in the dropdown.
-The event object contains the following custom properties:
Fired when a choice is being selected in the dropdown, but before any modification has been made to the selection.
This event is used to allow the user to reject selection by calling event.preventDefault()
The event object contains the following custom properties:
Fired when a choice is being cleared in the dropdown, but before any modification has been made to the selection.
This event is used to allow the user to reject the clear by calling event.preventDefault()
For the clear button to be visible the allowClear
option needs to be true
.
Fired when a choice is about to be removed in the dropdown/input, but before any removal of the choice has been made.
This event is used to allow the user to reject removal by calling event.preventDefault()
The event object contains the following custom properties:
Fired when a choice is removed or cleared.
-The event object contains the following custom properties:
Fired when query function is done loading the data and the results list has been updated
-The event object contains the following custom properties: