Selectable Widgetversion added: 1.0
Description: Use the mouse to select elements, individually or in a group.
The jQuery UI Selectable plugin allows for elements to be selected by dragging a box (sometimes called a lasso) with the mouse over the elements. Elements can also be selected via click or drag while holding the ctrl/meta key, allowing for multiple (non-contiguous) selections.
Dependencies
Additional Notes:
- This widget requires some functional CSS, otherwise it won't work. If you build a custom theme, use the widget's specific CSS file as a starting point.
Options
appendTo
"body"
Initialize the selectable with the appendTo
option specified:
1
2
3
|
|
Get or set the appendTo
option, after initialization:
1
2
3
4
5
|
|
autoRefresh
true
refresh()
method manually.Initialize the selectable with the autoRefresh
option specified:
1
2
3
|
|
Get or set the autoRefresh
option, after initialization:
1
2
3
4
5
|
|
cancel
"input,textarea,button,select,option"
Initialize the selectable with the cancel
option specified:
1
2
3
|
|
Get or set the cancel
option, after initialization:
1
2
3
4
5
|
|
delay
0
Initialize the selectable with the delay
option specified:
1
2
3
|
|
Get or set the delay
option, after initialization:
1
2
3
4
5
|
|
disabled
false
true
.Initialize the selectable with the disabled
option specified:
1
2
3
|
|
Get or set the disabled
option, after initialization:
1
2
3
4
5
|
|
distance
0
Initialize the selectable with the distance
option specified:
1
2
3
|
|
Get or set the distance
option, after initialization:
1
2
3
4
5
|
|
filter
"*"
Initialize the selectable with the filter
option specified:
1
2
3
|
|
Get or set the filter
option, after initialization:
1
2
3
4
5
|
|
tolerance
"touch"
-
"fit"
: Lasso overlaps the item entirely. -
"touch"
: Lasso overlaps the item by any amount.
Initialize the selectable with the tolerance
option specified:
1
2
3
|
|
Get or set the tolerance
option, after initialization:
1
2
3
4
5
|
|
Methods
destroy()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the destroy method:
1
|
|
disable()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the disable method:
1
|
|
enable()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the enable method:
1
|
|
instance()Returns: Object
Retrieves the selectable's instance object. If the element does not have an associated instance, undefined
is returned.
Unlike other widget methods, instance()
is safe to call on any element after the selectable plugin has loaded.
- This method does not accept any arguments.
Invoke the instance method:
1
|
|
option( optionName )Returns: Object
Gets the value currently associated with the specified optionName
.
Note: For options that have objects as their value, you can get the value of a specific key by using dot notation. For example, "foo.bar"
would get the value of the bar
property on the foo
option.
-
optionNameType: StringThe name of the option to get.
Invoke the method:
1
|
|
option()Returns: PlainObject
- This signature does not accept any arguments.
Invoke the method:
1
|
|
option( optionName, value )Returns: jQuery (plugin only)
Sets the value of the selectable option associated with the specified optionName
.
Note: For options that have objects as their value, you can set the value of just one property by using dot notation for optionName
. For example, "foo.bar"
would update only the bar
property of the foo
option.
-
optionNameType: StringThe name of the option to set.
-
valueType: ObjectA value to set for the option.
Invoke the method:
1
|
|
option( options )Returns: jQuery (plugin only)
-
optionsType: ObjectA map of option-value pairs to set.
Invoke the method:
1
|
|
refresh()Returns: jQuery (plugin only)
autoRefresh
option is set to false
.- This method does not accept any arguments.
Invoke the refresh method:
1
|
|
widget()Returns: jQuery
jQuery
object containing the selectable element.
- This method does not accept any arguments.
Invoke the widget method:
1
|
|
Events
create( event, ui )Type: selectablecreate
Note: The ui
object is empty but included for consistency with other events.
Initialize the selectable with the create callback specified:
1
2
3
|
|
Bind an event listener to the selectablecreate event:
1
|
|
selected( event, ui )Type: selectableselected
-
eventType: Event
-
uiType: Object
-
selectedType: ElementThe selectable item that has been selected.
-
Initialize the selectable with the selected callback specified:
1
2
3
|
|
Bind an event listener to the selectableselected event:
1
|
|
selecting( event, ui )Type: selectableselecting
-
eventType: Event
-
uiType: Object
-
selectingType: ElementThe current selectable item being selected.
-
Initialize the selectable with the selecting callback specified:
1
2
3
|
|
Bind an event listener to the selectableselecting event:
1
|
|
start( event, ui )Type: selectablestart
Note: The ui
object is empty but included for consistency with other events.
Initialize the selectable with the start callback specified:
1
2
3
|
|
Bind an event listener to the selectablestart event:
1
|
|
stop( event, ui )Type: selectablestop
Note: The ui
object is empty but included for consistency with other events.
Initialize the selectable with the stop callback specified:
1
2
3
|
|
Bind an event listener to the selectablestop event:
1
|
|
unselected( event, ui )Type: selectableunselected
-
eventType: Event
-
uiType: Object
-
unselectedType: ElementThe selectable item that has been unselected.
-
Initialize the selectable with the unselected callback specified:
1
2
3
|
|
Bind an event listener to the selectableunselected event:
1
|
|
unselecting( event, ui )Type: selectableunselecting
-
eventType: Event
-
uiType: Object
-
unselectingType: ElementThe current selectable item being unselected.
-
Initialize the selectable with the unselecting callback specified:
1
2
3
|
|
Bind an event listener to the selectableunselecting event:
1
|
|
Example:
A simple jQuery UI Selectable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
|