Documentation

UI/Droppable/droppable

From jQuery JavaScript Library

(Redirected from UI/Droppables/droppable)
Jump to: navigation, search

« Back to UI/Droppable

droppable( options )

Creates new droppables on the nodeset supplied by the query.
This jQuery plugin makes DOM nodes droppable (meaning they accept being dropped on by draggables). You can specify which (individually) or which kind of draggables each will accept.

All callbacks receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):

  • ui.options - options used to initialize the droppable
  • ui.position - current position of the draggable helper
  • ui.absolutePosition - current absolute position of the draggable helper
  • ui.draggable - current draggable element
  • ui.helper - current draggable helper
Arguments:
optionsOptions
A set of key/value pairs that configure the droppable. All options are optional.

Options:

NameType
acceptBoolean function(draggable)
This function is called for each draggable on the page, to provide a custom filter. Return true if draggable should be accepted.
acceptString
The string should be a jQuery selector. All draggables that match the selector will be accepted.
activeClassString
The class that should be added to the droppable while an acceptable draggable is being dragged.
greedyBoolean
If true, will prevent event propagation on nested droppables. Default value: false.
hoverClassString
The class that should be added to the droppable while being hovered by an acceptable draggable.
toleranceString
Specifies which mode to use for testing whether a draggable is 'over' a droppable. Possible values: 'fit', 'intersect', 'pointer', 'touch'. Default value: 'intersect'.
activatefunction(e, ui)
This function is called any time an accepted draggable starts dragging.
deactivatefunction(e, ui)
This function is called any time an accepted draggable stops dragging.
overfunction(e, ui)
This function is called as an accepted draggable is dragged 'over' (within the tolerance of) this droppable.
outfunction(e, ui)
This function is called when an accepted draggable is dragged out (within the tolerance of) this droppable.
dropfunction(e, ui)
This function is called when an accepted draggable is dropped 'over' (within the tolerance of) this droppable. In the callback, $(this) represents the droppable the draggable is dropped on. $(ui.draggable) represents the draggable.


droppable( "disable" )

Temporarily disable the droppable functionality.
This method temporarily disables droppable functionality. It can later be reenabled by calling $(..).droppable("enable").
Arguments:
"disable"String

droppable( "enable" )

Enable the droppable functionality.
This method re-enables a previously disabled droppable.
Arguments:
"enable"String

droppable( "destroy" )

Completely remove the droppable functionality.
This method removes the droppable functionality completely.
Arguments:
"destroy"String