Appendix K. Sortables

Method

Description

Return Value

Sortable Methods

sortable(options)

Makes the selected element(s) sortable. Options can be specified by passing an object literal as the first argument using key, value pairs. For a complete list of options, see the "Sortable Options" section later in this Appendix.

jQuery

sortable('disable')

Disables sortable functionality on the selected element(s).

jQuery

sortable('enable')

Enables sortable functionality on the selected element(s).

jQuery

sortable('destroy')

Completely removes sortable functionality from the selected element(s).

jQuery

sortable('serialize', options)

Returns a string of serialized IDs for each sortable item, which can then be used in an AJAX request or input form. For a complete list of options, see the "Serialize Options" section later in this Appendix.

String

sortable('refresh')

Refreshes the sortable items.

jQuery

sortable('refreshPositions')

Refreshes the cached positions of sortable items.

jQuery

Sortable Options

Option

Description

Type

appendTo

Defaults to the parent; defines where the helper that moves with the mouse is being appended to during the drag (e.g., to resolve overlap/zIndex issues).

String

axis

If specified, the items can only be dragged along either the X- or Y-axis. Only allows the values x or y.

One of x or y

cancel

Prevents sorting from beginning on elements that match the selector.

Selector

connectWith

Accepts an array of selectors, where the selector(s) match elements that are sortable elements. If this option is specified, ...

Get Beginning JavaScript® and CSS Development with jQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.