-
Notifications
You must be signed in to change notification settings - Fork 692
Methods
Interact with the multiselect instance after it has been initialized by calling any of the below methods.
// example:
$("#multiselect").multiselect("method_name");
open
Opens the menu.
close
Closes the menu.
refresh
Reloads the checkbox menu. If you're dynamically adding/removing option tags on the original select via AJAX or DOM manipulation methods, call refresh to reflect the changes in the widget.
Parameter:
init
If true, the refresh event is not triggered.
update
Updates the button text to reflect the number of current selections or the list of current selections, if the selectedList option is set.
Parameter:
isDefault
If true, the button text is also set as the default for the button to prevent form resets from reverting the text to the prior default value.
resync
Resynchonizes the widget's checkboxes with the selected states of the underlying native select options. This is useful if you set the value of the native select, then need to reflect the change in the widget.
Parameter:
skipDisabled
If true, disabled options are not changed.
disable
Disable the entire widget.
enable
Enable the entire widget.
checkAll
Check all checkboxes. If the optional groupID
parameter is supplied, only the options that are in the option group corresponding to groupID
(group index or group label) are checked.
Note: If the maxSelected option is set, this method will be ignored by the widget code.
uncheckAll
Uncheck all checkboxes. If the optional groupID
parameter is supplied, only the options that are in the option group corresponding to groupID
(group index or group label) are unchecked.
In single select mode, this will also clear the current selection.
flipAll
Invert (flip) all checkboxes. If the optional groupID
parameter is supplied, only the options that are in the option group corresponding to groupID
(group index or group label) are flipped.
Note: If the maxSelected option is set, this method may be ignored by the widget code, depending on how many checkboxes would be checked after the method runs.
collapseAll
Collapse all option groups. If the optional groupID
parameter is supplied, only the options that are in the option group corresponding to groupID
(group index or group label) are collapsed.
expandAll
Expand all option groups. If the optional groupID
parameter is supplied, only the options that are in the option group corresponding to groupID
(group index or group label) are expanded.
isOpen
Returns a boolean denoting if the widget is currently open or not.
buttonMessage
Displays a message in the widget button for 1 second.
Parameter:
message
The message to display.
getNamespaceID
Returns the namespace ID of the current widget instance.
getChecked
Returns an array of all the checked boxes.
getUnchecked
Returns an array of all the boxes that are not checked.
getButton
Returns the button element.
widget
Returns the menu container (all checkboxes inside).
option
Set or get one of the options after the widget has been initialized. If changing an option, the new option setting will take affect immediately.
destroy
Destroy the widget and return to the original select box.
getMenu
Returns the menu element for the widget.
getLabels
Returns the labels for the options within the widget, the inputs are children of these labels.
addOption
Allows you to add an option to the widget and the source element without the need for a refresh.
Parameters:
attributes
: Attributes object for the option element being added. Should at least contain a value.
text
: Text to display for the option
groupID
: If supplied, the option will be added under the option group with this index or textual label.
removeOption
Removes an option from the menu and source element that has the given value.
Parameters:
value
: The value attribute of the element to be removed.