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

Commit c43b6c6

Browse files
committed
Merge pull request #40 from thgreasi/master
Added Instructions about Canceling to README.
2 parents e8477b9 + 4404d20 commit c43b6c6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Apply the directive to your form elements:
2929
</ul>
3030
```
3131

32+
**Note:** `ng-model` is required, so that the directive knows which model to update.
33+
3234
### Options
3335

3436
All the jQueryUI Sortable options can be passed through the directive.
@@ -51,4 +53,20 @@ myAppModule.controller('MyController', function($scope) {
5153
</ul>
5254
```
5355

56+
#### Canceling
57+
58+
Inside the `update` callback, you can check the item that is dragged and cancel the sorting.
59+
60+
```js
61+
$scope.sortableOptions = {
62+
update: function(e, ui) {
63+
if (ui.item.scope().item == "can't be moved") {
64+
ui.item.parent().sortable('cancel');
65+
}
66+
}
67+
};
68+
```
69+
70+
**Note:** `update` occurs before any model/scope changes but after the DOM position has been updated.
71+
So `ui.item.scope` and the directive's `ng-model`, are equal to the scope before the drag start.
5472

0 commit comments

Comments
 (0)