|
| 1 | +# ui.item.sortable API documentation |
| 2 | + |
| 3 | +This refers to the additional properties that are exposed through the `ui` parameter in the provided callback hooks. eg: |
| 4 | +```js |
| 5 | +$scope.sortableOptions = { |
| 6 | + update: function(e, ui) { |
| 7 | + if (ui.item.sortable.model == "can't be moved") { |
| 8 | + ui.item.sortable.cancel(); |
| 9 | + } |
| 10 | + } |
| 11 | +}; |
| 12 | +``` |
| 13 | + |
| 14 | +## Properties |
| 15 | + |
| 16 | +**Note:** |
| 17 | +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. |
| 18 | + |
| 19 | +### dropindex |
| 20 | +Type: [Integer](http://api.jquery.com/Types/#Integer) |
| 21 | +Holds the index of the drop target that the dragged item was dropped. |
| 22 | + |
| 23 | + |
| 24 | +### droptarget |
| 25 | +Type: [jQuery](http://api.jquery.com/Types/#jQuery) |
| 26 | +Holds the ui-sortable element that the dragged item was dropped on. |
| 27 | + |
| 28 | +### droptargetModel |
| 29 | +Type: [Array](http://api.jquery.com/Types/#Array) |
| 30 | +Holds the array that is specified by the `ng-model` attribute of the [`droptarget`](#droptarget) ui-sortable element. |
| 31 | + |
| 32 | +### index |
| 33 | +Type: [Integer](http://api.jquery.com/Types/#Integer) |
| 34 | +Holds the original index of the item dragged. |
| 35 | + |
| 36 | +### model |
| 37 | +Type: [Object](http://api.jquery.com/Types/#Object) |
| 38 | +Holds the JavaScript object that is used as the model of the dragged item, as specified by the ng-repeat of the [`source`](#source) ui-sortable element and the item's [`index`](#index). |
| 39 | + |
| 40 | +### moved |
| 41 | +Type: [Object](http://api.jquery.com/Types/#Object)/`undefined` |
| 42 | +Holds the model of the dragged item only when a sorting happens between two connected ui-sortable elements. |
| 43 | +In other words: `'moved' in ui.item.sortable` will return false only when a sorting is withing the same ui-sortable element ([`source`](#source) equals to the [`droptarget`](#droptarget)). |
| 44 | + |
| 45 | +### received |
| 46 | +Type: [Boolean](http://api.jquery.com/Types/#Boolean) |
| 47 | +When sorting between two connected sortables, it will be set to true inside the `update` callback of the [`droptarget`](#droptarget). |
| 48 | + |
| 49 | +### source |
| 50 | +Type: [jQuery](http://api.jquery.com/Types/#jQuery) |
| 51 | +Holds the ui-sortable element that the dragged item originated from. |
| 52 | + |
| 53 | +### sourceModel |
| 54 | +Type: [Array](http://api.jquery.com/Types/#Array) |
| 55 | +Holds the array that is specified by the `ng-model` of the [`source`](#source) ui-sortable element. |
| 56 | + |
| 57 | + |
| 58 | +## Methods |
| 59 | + |
| 60 | +### cancel[()](http://api.jquery.com/Types/#Function) |
| 61 | +Returns: Nothing |
| 62 | +Can be called inside the `update` callback, in order to prevent/revert a sorting. |
| 63 | +Should be used instead of the [jquery-ui-sortable cancel()](http://api.jqueryui.com/sortable/#method-cancel) method. |
| 64 | + |
| 65 | +### isCanceled[()](http://api.jquery.com/Types/#Function) |
| 66 | +Returns: [Boolean](http://api.jquery.com/Types/#Boolean) |
| 67 | +Returns whether the current sorting is marked as canceled, by an earlier call to [`ui.item.sortable.cancel()`](#cancel). |
| 68 | + |
| 69 | +### isCustomHelperUsed[()](http://api.jquery.com/Types/#Function) |
| 70 | +Returns: [Boolean](http://api.jquery.com/Types/#Boolean) |
| 71 | +Returns whether the [`helper`](http://api.jqueryui.com/sortable/#option-helper) element used for the current sorting, is one of the original ui-sortable list elements. |
| 72 | + |
| 73 | + |
| 74 | +## Events |
| 75 | + |
| 76 | +### `ui-sortable:moved` |
| 77 | +Is emitted after the `stop` callback. |
| 78 | +In connected sortables it is also emitted after the `update` on the receiving sortable. |
| 79 | + |
| 80 | +```js |
| 81 | +$rootScope.$on('ui-sortable:moved', function (e, ui) { |
| 82 | + |
| 83 | +}); |
| 84 | +``` |
0 commit comments