Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Latest commit

 

History

History
84 lines (61 loc) · 3.26 KB

API.md

File metadata and controls

84 lines (61 loc) · 3.26 KB

ui.item.sortable API documentation

This refers to the additional properties that are exposed through the ui parameter in the provided callback hooks. eg:

$scope.sortableOptions = {
  update: function(e, ui) {
    if (ui.item.sortable.model == "can't be moved") {
      ui.item.sortable.cancel();
    }
  }
};

Properties

Note: The properties of ui.item.sortable object are cleared right after the stop callback fires. If you need to access them after the sorting ends, you should keep references in separate variables in your code.

dropindex

Type: Integer
Holds the index of the drop target that the dragged item was dropped.

droptarget

Type: jQuery
Holds the ui-sortable element that the dragged item was dropped on.

droptargetModel

Type: Array
Holds the array that is specified by the ng-model attribute of the droptarget ui-sortable element.

index

Type: Integer
Holds the original index of the item dragged.

model

Type: Object
Holds the JavaScript object that is used as the model of the dragged item, as specified by the ng-repeat of the source ui-sortable element and the item's index.

moved

Type: Object/undefined
Holds the model of the dragged item only when a sorting happens between two connected ui-sortable elements.
In other words: 'moved' in ui.item.sortable will return false only when a sorting is withing the same ui-sortable element (source equals to the droptarget).

received

Type: Boolean
When sorting between two connected sortables, it will be set to true inside the update callback of the droptarget.

source

Type: jQuery
Holds the ui-sortable element that the dragged item originated from.

sourceModel

Type: Array
Holds the array that is specified by the ng-model of the source ui-sortable element.

Methods

cancel()

Returns: Nothing
Can be called inside the update callback, in order to prevent/revert a sorting.
Should be used instead of the jquery-ui-sortable cancel() method.

isCanceled()

Returns: Boolean
Returns whether the current sorting is marked as canceled, by an earlier call to ui.item.sortable.cancel().

isCustomHelperUsed()

Returns: Boolean
Returns whether the helper element used for the current sorting, is one of the original ui-sortable list elements.

Events

ui-sortable:moved

Is emitted after the stop callback. In connected sortables it is also emitted after the update on the receiving sortable.

$rootScope.$on('ui-sortable:moved', function (e, ui) {
    
});