Sortable(options)
Allows you to resort elements within a container by dragging and dropping. Requires the Draggables and Droppables plugins. The container and each item inside the container must have an ID. Sortables are especially useful for lists.
参数
- options (Hash): A hash of options
Hash 选项
- accept (String): The class name for items inside the container (mandatory)
- activeclass (String): The class for the container when one of its items has started to move
- hoverclass (String): The class for the container when an acceptable item is inside it
- helperclass (String): The helper is used to point to the place where the item will be moved. This is the class for the helper.
- opacity (Float): Opacity (between 0 and 1) of the item while being dragged
- ghosting (Boolean): When true, the sortable is ghosted when dragged
- tolerance (String): Either 'pointer', 'intersect', or 'fit'. See Droppable for more details
- fit (Boolean): When true, sortable must be inside the container in order to drop
- fx (Integer): Duration for the effect applied to the sortable
- onchange (Function): Callback that gets called when the sortable list changed. It takes an array of serialized elements
- floats (Boolean): True if the sorted elements are floated
- containment (String): Use 'parent' to constrain the drag to the container
- axis (String): Use 'horizontally' or 'vertically' to constrain dragging to an axis
- handle (String): The jQuery selector that indicates the draggable handle
- handle (DOMElement): The node that indicates the draggable handle
- onHover (Function): Callback that is called when an acceptable item is dragged over the container. Gets the hovering DOMElement as a parameter
- onOut (Function): Callback that is called when an acceptable item leaves the container. Gets the leaving DOMElement as a parameter
- cursorAt (Object): The mouse cursor will be moved to the offset on the dragged item indicated by the object, which takes "top", "bottom", "left", and "right" keys
- onStart (Function): Callback function triggered when the dragging starts
- onStop (Function): Callback function triggered when the dragging stops
示例
jQuery 代码:
$('ul').Sortable( { accept : 'sortableitem', activeclass : 'sortableactive', hoverclass : 'sortablehover', helperclass : 'sorthelper', opacity: 0.5, fit : false } )
|