The sortable () Method

The sortable () method can be used in two forms:

  • $(selector, context).sortable (options)

  • $(selector, context).sortable ("action", params)

The sortable (options) Method

The sortable (options) method declares that an HTML element contains interchangeable elements. The options parameter is an object that specifies behavior in the permutation. Among the options available, many are similar to those we studied in the draggable (options) method (Chapter 10).

Specifying and managing the movable elements

The options listed in Table 12-1 allow you to indicate which items can be moved for switching. By default, all items that are in the descendants of the elements on which the sortable (options) method applies are movable. Use these options to inhibit the movement for all items or only some, or even move a new item created on the fly. Table 12-2 describes the options for managing the specified movable elements.

Table 12-1. Options for specifying the movable elements




When set to true, disables the movement of elements. No displacement or deposit of elements will be considered until these elements are returned enabled (using the sortable ("enable") instruction).


A selector representing the elements for which the displacement is prohibited. Users cannot start swapping by clicking on any of these items. This allows you to restrict the start list items (those on which the sortable (options) method applies).


Indicates that we ...

Get jQuery UI now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.