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

Commit 176ab1f

Browse files
committed
Call apply after stop callback.
Ensure $scope.$apply() is called after any provided 'stop' callback.
1 parent 3e7dffc commit 176ab1f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/sortable.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ angular.module('ui.sortable', [])
3030
stop:null,
3131
update:null
3232
};
33+
34+
var apply = function(e, ui) {
35+
if (ui.item.sortable.resort || ui.item.sortable.relocate) {
36+
scope.$apply();
37+
}
38+
};
3339

3440
angular.extend(opts, uiSortableConfig);
3541

@@ -77,9 +83,6 @@ angular.module('ui.sortable', [])
7783
ui.item.sortable.resort.$modelValue.splice(end, 0, ui.item.sortable.resort.$modelValue.splice(start, 1)[0]);
7884

7985
}
80-
if (ui.item.sortable.resort || ui.item.sortable.relocate) {
81-
scope.$apply();
82-
}
8386
};
8487

8588
}
@@ -91,6 +94,11 @@ angular.module('ui.sortable', [])
9194
if( callbacks[key] ){
9295
// wrap the callback
9396
value = combineCallbacks( callbacks[key], value );
97+
98+
if ( key === 'stop' ){
99+
// call apply after stop
100+
value = combineCallbacks( value, apply );
101+
}
94102
}
95103

96104
element.sortable('option', key, value);
@@ -101,6 +109,9 @@ angular.module('ui.sortable', [])
101109

102110
opts[key] = combineCallbacks(value, opts[key]);
103111
});
112+
113+
// call apply after stop
114+
opts.stop = combineCallbacks( opts.stop, apply );
104115

105116
// Create sortable
106117

0 commit comments

Comments
 (0)