O'Reilly logo

jQuery UI by Eric Sarrion

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

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

Option

Function

options.disabled

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).

options.cancel

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).

options.helper

Indicates that we ...

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