Fires when item dragging ends but before the item's position is changed in the DOM. This event is suitable for preventing the sort action.

Event Data

e.action String

Possible values are: "sort" - indicates that item's position was changed inside the same Sortable container; "remove" - indicates that the item was removed from current Sortable widget; "receive" - indicates that the item was received by a connected Sortable widget instance;

e.preventDefault Function

If invoked prevents the sort action. The element will be reverted at its original position. The hint and placeholder will be destroyed.

e.item jQuery

The element that is dragged.

e.oldIndex Number

The original position of the item in the Sortable collection. In case the item is received from connected Sortable the value will be -1

e.newIndex Number

The position where item will be placed. In case the item is removed from connected Sortable the value will be -1

e.draggableEvent Object

The original draggable's drag event data.


<ul id="sortable">

        end: function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
            console.log("from " + e.oldIndex + " to " + e.newIndex);

            //prevent first item to be placed at the end of the list
            if(e.newIndex == 2 && e.oldIndex == 0) {
In this article