The jQuery UI singleselect and multiselect listbox plugin.
- Source:
Members
autoSort :boolean
Enable auto sorting. Default false.
Type:
- boolean
- Source:
isSortByDataProp :boolean
Determines whether sorting will be done by `sort_order` property of the related data. Default null, what does sort by item text mean. If true, then sort by `sort_order` property of the related data. If false, then sort by value.
Type:
- boolean
- Source:
items :Array.<lb_item>
The initial array of item objects to populate the listbox. Used for initialization only.
Type:
- Array.<lb_item>
- Source:
multiSelect :sting
This is a multiselect listbox, otherwise it is a singleselect listbox. Default false.
Type:
- sting
- Source:
name :boolean
The HTML `name` attribute identifier. Default `lb_name<uuid>`. Note: When there is more than one listbox with the same name on one page, there will be display and functionality issues!
Type:
- boolean
- Source:
quiet :boolean
Disable call `onChange`. Default false.
Type:
- boolean
- Source:
sortOrder :string
Sort data key. Default null.
Type:
- string
- Source:
sortOrderStep :number
`sort_order` data key increment step for auto sorting. Default 10.
Type:
- number
- Source:
sortable :boolean
Allowed to sort manually by dragging items. Default false.
Type:
- boolean
- Source:
Methods
add(item, is_quietopt, eopt)
Adds a item.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
item |
lb_item | Item data. | ||
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
clear(is_quietopt, eopt)
Deletes all items.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. |
- Source:
delete(value, is_quietopt, eopt) → {boolean}
Deletes the specified item.
See also: remove().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
string | Item value. | ||
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
Returns:
Whether the specified items were found and deleted.
- Type
- boolean
first() → {string}
Gets the first item value.
See also: last().
- Source:
Returns:
The first item value.
- Type
- string
getAllData(is_as_arrayopt, is_return_textopt, text_aliasopt) → {array|object}
Gets assigned data.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
is_as_array |
boolean |
<optional> |
false | Whether to return the result as an array (sorted as in the listbox control), otherwise return the object (when iterating over the properties of this object, the result will be sorted by value). Default false. |
is_return_text |
boolean |
<optional> |
false | Update data object field with the item text. Default false. |
text_alias |
string |
<optional> |
"" | From which property of the data to take the value of the text. Default is empty string, which means take it from the `text` property of the data object. |
- Source:
Returns:
Assigned data.
- Type
- array | object
getData() → {object}
- Source:
Returns:
Related user-defined data.
- Type
- object
getDataVar(key)
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | Property key. |
- Source:
Returns:
Property value.
getItem(value, is_with_dataopt) → {lb_item}
Gets item object by an item value.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
string | An item value. | ||
is_with_data |
boolean |
<optional> |
true | Whether to return assigned data. Default true. |
- Source:
Returns:
Item object.
- Type
- lb_item
getItemData(value) → {object}
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | An item value. |
- Source:
Returns:
Related user-defined data.
- Type
- object
getItemDataVar(value, key)
Gets user-defined data property by item value and property key.
See also: getDataVar(), setItemDataVar(), setItemDataVar().
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | An item value. |
key |
string | Property key. |
- Source:
Returns:
Property value.
getItemIndex(value) → {number}
Gets an item index by value.
See also: index().
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | Item value. |
- Source:
Returns:
The item index.
- Type
- number
getItemText(value) → {string}
Gets item text by value.
See also: getText(), setItemText().
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | An item value. |
- Source:
Returns:
Item text.
- Type
- string
getSortOrder() → {number}
Returns `sort_order` property of the related data.
See also: setSortOrder().
- Source:
Returns:
`sort_order` property of the related data.
- Type
- number
getText() → {string}
Gets selected item text.
See also: getItemText(), setText().
- Source:
Returns:
Item text.
- Type
- string
hasItem(value) → {boolean}
Checks if an element with the specified value exists.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | An item value. |
- Source:
Returns:
Does the element exist.
- Type
- boolean
hasSelected() → {boolean}
Checks if at least one item is selected.
- Source:
Returns:
At least one item is selected.
- Type
- boolean
index() → {boolean}
Gets the specified item index.
See also: getItemIndex().
- Source:
Returns:
The item index.
- Type
- boolean
insert(index, item, is_quietopt, eopt)
Inserts a item into the specified position.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
index |
number | Insert position. `autoSort` option can change position after insetrtion. | ||
item |
lb_item | Item data. | ||
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
item(is_with_dataopt) → {lb_item}
Gets selected item object.
See also: items().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
is_with_data |
boolean |
<optional> |
true | Whether to return assigned data. Default true. |
- Source:
Returns:
Selected item object.
- Type
- lb_item
items(is_with_dataopt) → {array}
Gets list of selected items.
See also: item().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
is_with_data |
boolean |
<optional> |
true | Whether to return assigned data. Default true. |
- Source:
Returns:
List of items.
- Type
- array
last() → {string}
Gets the last item value.
See also: first().
- Source:
Returns:
The last item value.
- Type
- string
length() → {number}
Returns the number of items.
- Source:
Returns:
Number of elements.
- Type
- number
remove(is_quietopt, eopt) → {boolean}
Removes the selected items.
See also: delete().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
Returns:
Whether the selected items were found and removed.
- Type
- boolean
replace(is_quietopt, eopt)
Deletes all items and insert specified new items.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
replaceData(new_data, is_update_textopt, text_aliasopt)
Replaces the user-defined data with a new object.
See also: replaceItemData(), getData(), updateData().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
new_data |
object | Data object. | ||
is_update_text |
string |
<optional> |
false | Whether to update the item text. Default false. |
text_alias |
string |
<optional> |
"" | From which property of the data to take the value of the text. Default is empty string, which means take it from the `text` property of the data object. |
- Source:
replaceItemData(value, new_data, is_update_textopt, text_aliasopt)
Replaces the user-defined data with a new object by item value.
See also: getItemData(), updateItemData(), replaceData().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
string | An item value. | ||
new_data |
object | Data object. | ||
is_update_text |
string |
<optional> |
false | Whether to update the item text. Default false. |
text_alias |
string |
<optional> |
"" | From which property of the data to take the value of the text. Default is empty string, which means take it from the `text` property of the data object. |
- Source:
select(value, is_quietopt, eopt)
Selects the specified item or multiple specified items for multiselect.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
string | Array.<string> | An item value, or an array of item values. If the value is null or undefined, the selection is removed. For singleselect selects the last item in the array. | ||
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
setDataVar(key, prop)
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | Property key. |
prop |
string | Property value. |
- Source:
setItemDataVar(value, key, prop)
Sets user-defined data property by item value and property key.
See also: setDataVar(), unsetItemDataVar(), getItemDataVar().
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | An item value. |
key |
string | Property key. |
prop |
string | Property value. |
- Source:
setItemText(value, text)
Sets item text by value.
See also: setText(), getItemText().
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | An item value. |
text |
string | New text for the item. |
- Source:
setItemVal(value, new_value, is_quietopt, eopt)
Replaces item value by item value.
See also: setVal().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
string | An item value. | ||
new_value |
string | New item value. | ||
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
setSortOrder(sort_order)
Sets `sort_order` property of the related data.
See also: getSortOrder().
Parameters:
| Name | Type | Description |
|---|---|---|
sort_order |
number | `sort_order` value. |
- Source:
setText(text)
Sets selected item text.
See also: setItemText(), getText().
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | New text for the selected item. |
- Source:
setVal(new_value, is_quietopt, eopt)
Replaces selected item value.
See also: setItemVal().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
new_value |
string | New item value. | ||
is_quiet |
boolean |
<optional> |
false | Disable or enable call `onChange`. Default false. |
e |
object |
<optional> |
null | jQuery event or another data which will be transferred to `onChange`. Default null. |
- Source:
sort()
Sorts items.
See also: sortBy().
- Source:
sortBy(is_sort_by_data_propopt)
Sorts items.
See also: sort().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
is_sort_by_data_prop |
boolean |
<optional> |
null | Determines whether sorting will be done by `sort_order` property of the related data. Default null, what does sort by item text mean. If true, then sort by `sort_order` property of the related data. If false, then sort by value. |
- Source:
unsetDataVar(key)
Unsets a user-defined data property property by key.
See also: getItemDataVar(), setDataVar(), setDataVar().
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | Property key. |
- Source:
unsetItemDataVar(value, key)
Unsets a user-defined data property property by item value and property key.
See also: getDataVar(), setItemDataVar(), setItemDataVar().
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | An item value. |
key |
string | Property key. |
- Source:
updateData(data, is_update_textopt, text_aliasopt)
Updates related user-defined data. All unaffected properties remain unchanged.
See also: updateItemData(), getData(), replaceData().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
object | Data object. | ||
is_update_text |
string |
<optional> |
false | Whether to update the item text. Default false. |
text_alias |
string |
<optional> |
"" | From which property of the data to take the value of the text. Default is empty string, which means take it from the `text` property of the data object. |
- Source:
updateItemData(value, data, is_update_textopt, text_aliasopt)
Updates related user-defined data by item value. All unaffected properties remain unchanged.
See also: getItemData(), replaceItemData(), updateData().
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
string | An item value. | ||
data |
object | Data object. | ||
is_update_text |
string |
<optional> |
false | Whether to update the item text. Default false. |
text_alias |
string |
<optional> |
"" | From which property of the data to take the value of the text. Default is empty string, which means take it from the `text` property of the data object. |
- Source:
val() → {string}
Returns selected item value.
- Source:
Returns:
Selected item value.
- Type
- string
vals() → {array}
Returns selected items values.
- Source:
Returns:
Selected items values.
- Type
- array
Type Definitions
lb_item
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
val |
sting | Associated value. When used inside a HTML form, it will be passed in the request. |
text |
sting | Display text. |
class |
sting | Optional. Custom css class of the item. |
sort_order |
number | Optional. Custom sort order. |
data |
object | Optional. Related user-defined data. Automatic or manual sorting changes or creates the `sort_order` property. |
- Source: