Reorderable

Drag-to-sort list. By default each item shows a fa-grip-vertical handle on the left — drag from the handle to reorder. Handles can be hidden with ->handles(false), which restores the classic grip-dot gutter and makes the entire item draggable. Supports optional server-side persistence when ->updateModelOnReorder() and ->updateUrl() are set.

Basic Reorderable (with handles)

Drag the handle on any item to reorder. The output reflects the updated key order.

First task
Drag handle to reorder
Second task
Drag handle to reorder
Third task
Drag handle to reorder
Fourth task
Drag handle to reorder
Saving...
Reorder items to see output...
PHP

No handles (classic grip-dot gutter)

Use ->handles(false) to hide the handle icon and revert to the classic grip-dot gutter — the entire item becomes draggable.

Alpha
Beta
Gamma
Saving...
Reorder items to see output...
PHP

PHP PHP Methods (Fluent)

Method / PropertyParametersDescription
$m->reorderable($id)stringCreate a reorderable component.
->items($items)arraySet items. Each: {key, html, id?, class?, attrs?}.
->handles($show)boolShow grip handle icon on each item. Default: true. Pass false to use the classic grip-dot gutter (whole item draggable).
->updateModelOnReorder($enabled)boolAuto-POST new order to server after each drag. Default: false.
->updateUrl($url)?stringURL to POST the reordered keys to.
->emptyMessage($msg)?stringMessage shown when there are no items.
->loaderText($text)stringLoading indicator text (default: "Saving...").

JS JS Methods

Method / PropertyParametersDescription
m.reorderable(id, opts)string, ?objectGet or create reorderable instance.
getOrder()Returns array of item keys in current visual order.
addItem(key, html, opts)string, string, ?objectAppend a new item (handle injected automatically if enabled).
upsertItem(key, html, opts)string, string, ?objectUpdate existing item or insert if not found (handle injected automatically if enabled).
removeItem(key)stringRemove an item by key.
clear()Remove all items.
count()Returns number of items.
getItems()Returns array of item DOM elements.

EVENT Events

Event NameDetailDescription
m:reorderable:reorder{id, order}Fired after items are drag-reordered (before server call).
m:reorderable:saved{id, order, response}Fired after server confirms the new order.
m:reorderable:error{id, order, error}Fired if the reorder POST fails.