说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

Sortable(options)-JQuery API

HTML文档下载 WORD文档下载 PDF文档下载
Sortable(options)允许你通过拖放对容器里的元素重新排序. 需要拖放插件.

Sortable(options)

允许你通过拖放对容器里的元素重新排序. 需要拖放插件. 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 } )

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘