You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
@@ -51,9 +53,9 @@ Apply the directive to your form elements:
51
53
**Developing Notes:**
52
54
53
55
*`ng-model` is required, so that the directive knows which model to update.
54
-
*`ui-sortable` element should only contain one `ng-repeat` and not any other elements (above or below).
55
-
Otherwise the index matching of the generated DOM elements and the `ng-model`'s items will break.
56
-
**In other words: The items of `ng-model` must match the indexes of the generated DOM elements.**
56
+
*`ui-sortable` element should contain only one `ng-repeat`, but other non-repeater elements above or below may still exist.
57
+
Otherwise the index matching of the `ng-model`'s items and the DOM elements generated by the `ng-repeat` will break.
58
+
**In other words: The items of `ng-model` must match the indexes of the DOM elements generated by the `ng-repeat`.**
57
59
*[`Filters`](https://docs.angularjs.org/guide/filter) that manipulate the model (like [filter](https://docs.angularjs.org/api/ng/filter/filter), [orderBy](https://docs.angularjs.org/api/ng/filter/orderBy), [limitTo](https://docs.angularjs.org/api/ng/filter/limitTo),...) should be applied in the `controller` instead of the `ng-repeat` (refer to [the provided examples](#examples)).
58
60
This is the preferred way since it:
59
61
- is performance wise better
@@ -90,15 +92,9 @@ The suggested pattern is to use callbacks for emmiting events and altering the s
90
92
91
93
#### Floating
92
94
93
-
**Update**: Issue [~~7498~~](bugs.jqueryui.com/ticket/7498) was resolved in jquery-ui v1.11.4.
94
-
Calling `angular.element('ui-sortable').sortable('refresh')` (use a more appropriate selector in your use case)
95
-
should make jquery-ui-sortable recognize the position and orientation of the existing and any new items.
96
-
As a result, since ui-sortable makes a call to `sortable('refresh')` after the sortable items are created by the repeater, it is not any more necessary to use the `ui-floating` property if the orientation of your list is not changing dynamically.
97
-
**TL;DR:** If you are using jquery-ui v1.11.4+ and you are not changing the orientation of your list dynamically, then you probably don't need to use `ui-floating` property.
98
-
99
95
To have a smooth horizontal-list reordering, jquery.ui.sortable needs to detect the orientation of the list.
100
96
This detection takes place during the initialization of the plugin (and some of the checks include: whether the first item is floating left/right or if 'axis' parameter is 'x', etc).
101
-
There is also a [known issue](bugs.jqueryui.com/ticket/7498) about initially empty horizontal lists.
97
+
There is also a [known issue](https://bugs.jqueryui.com/ticket/7498) about initially empty horizontal lists.
102
98
103
99
To provide a solution/workaround (till jquery.ui.sortable.refresh() also tests the orientation or a more appropriate method is provided), ui-sortable directive provides a `ui-floating` option as an extra to the [jquery.ui.sortable options](http://api.jqueryui.com/sortable/).
104
100
@@ -146,7 +142,19 @@ $scope.sortableOptions = {
146
142
**Notes:**
147
143
*`update` is the appropriate place to cancel a sorting, since it occurs before any model/scope changes but after the DOM position has been updated.
148
144
So `ui.item.scope` and the directive's `ng-model`, are equal to the scope before the drag start.
149
-
* To [cancel a sorting between connected lists](https://github.com/angular-ui/ui-sortable/issues/107#issuecomment-33633638), `cancel` should be called inside the `update` callback of the originating list.
145
+
* To [cancel a sorting between connected lists](https://github.com/angular-ui/ui-sortable/issues/107#issuecomment-33633638), `cancel` should be called inside the `update` callback of the originating list. A simple way to is to use the `ui.item.sortable.received` property:
146
+
```js
147
+
update:function(event, ui) {
148
+
if (// ensure we are in the first update() callback
149
+
!ui.item.sortable.received&&
150
+
// check that its an actual moving between the two lists
The karma task will try to open Firefox and Chrome as browser in which to run the tests. Make sure this is available or change the configuration in `test\karma.conf.js`
243
+
The karma task will try to open Firefox and Chrome as browser in which to run the tests. Make sure this is available or change the configuration in `test\karma.conf.js`.
0 commit comments