Droppable Widgetversion added: 1.0
Description: Create targets for draggable elements.
The jQuery UI Droppable plugin makes selected elements droppable (meaning they accept being dropped on by draggables). You can specify which draggables each will accept.
Options
accept
"*"
- Selector: A selector indicating which draggable elements are accepted.
-
Function: A function that will be called for each draggable on the page (passed as the first argument to the function). The function must return
true
if the draggable should be accepted.
activeClass
false
addClasses
true
false
, will prevent the ui-droppable
class from being added. This may be desired as a performance optimization when calling .droppable()
init on hundreds of elements.greedy
false
true
, any parent droppables will not receive the element.hoverClass
false
scope
"default"
accept
option. A draggable with the same scope value as a droppable will be accepted.tolerance
"intersect"
-
"fit"
: Draggable overlaps the droppable entirely. -
"intersect"
: Draggable overlaps the droppable at least 50% in both directions. -
"pointer"
: Mouse pointer overlaps the droppable. -
"touch"
: Draggable overlaps the droppable any amount.
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
|
|
option( optionName )Returns: Object
optionName
.-
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)
optionName
.-
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
|
|
widget()Returns: jQuery
jQuery
object containing the droppable element.
- This method does not accept any arguments.
Invoke the widget method:
1
|
|
Events
activate( event, ui )Type: droppableactivate
-
eventType: Event
-
uiType: Object
-
draggableType: jQueryA jQuery object representing the draggable element.
-
helperType: jQueryA jQuery object representing the helper that is being dragged.
-
positionType: ObjectCurrent CSS position of the draggable helper as
{ top, left }
object. -
offsetType: ObjectCurrent offset position of the draggable helper as
{ top, left }
object.
-
Initialize the droppable with the activate callback specified:
1
2
3
|
|
Bind an event listener to the droppableactivate event:
1
|
|
create( event, ui )Type: droppablecreate
Note: The ui
object is empty but included for consistency with other events.
Initialize the droppable with the create callback specified:
1
2
3
|
|
Bind an event listener to the droppablecreate event:
1
|
|
deactivate( event, ui )Type: droppabledeactivate
-
eventType: Event
-
uiType: Object
-
draggableType: jQueryA jQuery object representing the draggable element.
-
helperType: jQueryA jQuery object representing the helper that is being dragged.
-
positionType: ObjectCurrent CSS position of the draggable helper as
{ top, left }
object. -
offsetType: ObjectCurrent offset position of the draggable helper as
{ top, left }
object.
-
Initialize the droppable with the deactivate callback specified:
1
2
3
|
|
Bind an event listener to the droppabledeactivate event:
1
|
|
drop( event, ui )Type: droppabledrop
tolerance
option).-
eventType: Event
-
uiType: Object
-
draggableType: jQueryA jQuery object representing the draggable element.
-
helperType: jQueryA jQuery object representing the helper that is being dragged.
-
positionType: ObjectCurrent CSS position of the draggable helper as
{ top, left }
object. -
offsetType: ObjectCurrent offset position of the draggable helper as
{ top, left }
object.
-
Initialize the droppable with the drop callback specified:
1
2
3
|
|
Bind an event listener to the droppabledrop event:
1
|
|
out( event, ui )Type: droppableout
tolerance
option).Note: The ui
object is empty but included for consistency with other events.
Initialize the droppable with the out callback specified:
1
2
3
|
|
Bind an event listener to the droppableout event:
1
|
|
over( event, ui )Type: droppableover
tolerance
option).-
eventType: Event
-
uiType: Object
-
draggableType: jQueryA jQuery object representing the draggable element.
-
helperType: jQueryA jQuery object representing the helper that is being dragged.
-
positionType: ObjectCurrent CSS position of the draggable helper as
{ top, left }
object. -
offsetType: ObjectCurrent offset position of the draggable helper as
{ top, left }
object.
-
Initialize the droppable with the over callback specified:
1
2
3
|
|
Bind an event listener to the droppableover event:
1
|
|
Example:
A pair of draggable and droppable elements.
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
34
35
36
37
38
39
40
41
42
|
|