O'Reilly logo

Ajax on Rails by Scott Raymond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drag and Drop

script.aculo.us’ drag-and-drop functionality (defined in dragdrop.js) is provided by one class (Draggable) and three objects: Draggables (which manages instances of Draggable), Droppables, and Sortables.

class Draggable

initialize( element[, options] )

Creates a Draggable instance for element and registers it by calling Draggables.register.

Options may include:

handle
May be false (the default, making the element its own handle), an element object, or a string that sets handle to the first child of element with the given class name. 
starteffect
An effect called on element when dragging starts. By default, it changes element’s opacity to 0.2 in 0.2 seconds. 
reverteffect
An effect called on element when the drag is reverted. Defaults to a smooth slide to element’s original position. 
endeffect
An effect called on element when dragging ends. By default, it changes element’s opacity to 1.0 in 0.2 seconds. 
constraint
A string used to limit the draggable directions, either horizontal or vertical. Defaults to null. 
zindex
Sets the CSS zindex property. Defaults to 1000. 
revert
Boolean indicating whether the draggable should slide back to its starting point after being dropped. Can also be an arbitrary function reference, called when the drag ends. Defaults to false. 
scroll
Boolean determining whether the draggable should cause the page to scroll when dragged near the edge. Defaults to false. 
scrollSensitivity
Determines the size in pixels of the area in which the pointer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required