Optional
config: SortableConfigLisnUsageError If there are less than 2 items given or found.
Readonly
destroyUndoes all modifications to the element and returns it to its original state.
You will need to recreate it if you want to enable its functionality again.
Readonly
disableDisables the functionality of the widget. What this means is specific to each widget.
Readonly
disableDisables the given item number. Note that item numbers start at 1.
Optional
currentOrder: booleanIf false (default), the item numbers refer to the original order. If true, they refer to the current document order.
Readonly
enableRe-enables the functionality of the widget. What this means is specific to each widget.
Readonly
enableRe-enables the given item number. Note that item numbers start at 1.
Optional
currentOrder: booleanIf false (default), the item numbers refer to the original order. If true, they refer to the current document order.
Readonly
getReturns the element passed to the widget constructor.
Readonly
getReturns the item elements.
Optional
currentOrder: booleanIf false (default), returns the items in the original order. If true, they are returned in the current document order.
Readonly
isReturns true if the widget is destroyed.
Readonly
isReturns true if the widget is currently disabled.
Readonly
isReturns true if the given item number is disabled. Note that item numbers start at 1.
Optional
currentOrder: booleanIf false (default), the item numbers refer to the original order. If true, they refer to the current document order.
Readonly
onThe given handler will be called when the widget is destroyed.
Readonly
onThe given handler will be called when the widget is disabled.
Readonly
onThe given handler will be called when the widget is enabled.
Readonly
onThe given handler will be called whenever the user moves an item to
another position. It will be called after the item is moved so
getItems called with currentOrder = true
will return the updated
order.
If the handler returns a promise, it will be awaited upon.
Readonly
toggleRe-enables the widget if disabled, otherwise disables it.
Readonly
toggleRe-enables the given item number if it is disabled, otherwise disables it. Note that item numbers start at 1.
Optional
currentOrder: booleanIf false (default), the item numbers refer to the original order. If true, they refer to the current document order.
Configures the given element as a Sortable widget.
The Sortable widget allows the user to reorder elements by dragging and dropping. It works on touch devices as well. However, it does not yet support automatic scrolling when dragging beyond edge of screen on mobile devices. For this, you may want to use SortableJS instead.
The widget should have more than one draggable item.
IMPORTANT: You should not instantiate more than one Sortable widget on a given element. Use Sortable.get to get an existing instance if any. If there is already a widget instance, it will be destroyed!
You can use the following dynamic attributes or CSS properties in your stylesheet:
The following dynamic attributes are set on each item element:
data-lisn-is-draggable
:"true"
or"false"
(false if the item is disabled)To use with auto-widgets (HTML API) (see settings.autoWidgets), the following CSS classes or data attributes are recognized:
lisn-sortable
class ordata-lisn-sortable
attribute set on the container element that constitutes the sortable containerlisn-sortable-item
class ordata-lisn-sortable-item
attribute set on elements that should act as the items.When using auto-widgets, the elements that will be used as items are discovered in the following way:
lisn-sortable-item
class ordata-lisn-sortable-item
attribute. They do not have to be immediate children of the root element.script
andstyle
elements) are taken as the items.Example