@@ -44,6 +44,8 @@ angular.module('ui.sortable', [])
44
44
scope . $watch ( attrs . ngModel + '.length' , function ( ) {
45
45
// Timeout to let ng-repeat modify the DOM
46
46
$timeout ( function ( ) {
47
+ // ensure that the jquery-ui-sortable widget instance
48
+ // is still bound to the directive's element
47
49
if ( ! ! element . data ( 'ui-sortable' ) ) {
48
50
element . sortable ( 'refresh' ) ;
49
51
}
@@ -176,18 +178,23 @@ angular.module('ui.sortable', [])
176
178
} ;
177
179
178
180
scope . $watch ( attrs . uiSortable , function ( newVal /*, oldVal*/ ) {
179
- angular . forEach ( newVal , function ( value , key ) {
180
- if ( callbacks [ key ] ) {
181
- if ( key === 'stop' ) {
182
- // call apply after stop
183
- value = combineCallbacks (
184
- value , function ( ) { scope . $apply ( ) ; } ) ;
181
+ // ensure that the jquery-ui-sortable widget instance
182
+ // is still bound to the directive's element
183
+ if ( ! ! element . data ( 'ui-sortable' ) ) {
184
+ angular . forEach ( newVal , function ( value , key ) {
185
+ if ( callbacks [ key ] ) {
186
+ if ( key === 'stop' ) {
187
+ // call apply after stop
188
+ value = combineCallbacks (
189
+ value , function ( ) { scope . $apply ( ) ; } ) ;
190
+ }
191
+ // wrap the callback
192
+ value = combineCallbacks ( callbacks [ key ] , value ) ;
185
193
}
186
- // wrap the callback
187
- value = combineCallbacks ( callbacks [ key ] , value ) ;
188
- }
189
- element . sortable ( 'option' , key , value ) ;
190
- } ) ;
194
+
195
+ element . sortable ( 'option' , key , value ) ;
196
+ } ) ;
197
+ }
191
198
} , true ) ;
192
199
193
200
angular . forEach ( callbacks , function ( value , key ) {
0 commit comments