This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree 1 file changed +18
-18
lines changed
1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -230,8 +230,7 @@ angular.module('ui.sortable', [])
230
230
return ;
231
231
}
232
232
233
- if ( ngModel ) {
234
-
233
+ function init ( ) {
235
234
// When we add or remove elements, we need the sortable to 'refresh'
236
235
// so it can find the new/removed elements.
237
236
scope . $watchCollection ( 'ngModel' , function ( ) {
@@ -443,30 +442,31 @@ angular.module('ui.sortable', [])
443
442
} , true ) ;
444
443
445
444
patchUISortableOptions ( opts ) ;
446
-
447
- } else {
448
- $log . info ( 'ui.sortable: ngModel not provided!' , element ) ;
449
445
}
450
446
451
447
var stopDisabledWatcher = angular . noop ;
452
448
453
- var startIfEnabled = function ( )
454
- {
455
- if ( ! scope . uiSortable . disabled )
456
- {
457
- // Create sortable
458
- element . sortable ( opts ) ;
459
-
460
- // Stop Watcher
461
- stopDisabledWatcher ( ) ;
449
+ var startIfEnabled = function ( ) {
450
+ if ( scope . uiSortable && scope . uiSortable . disabled ) {
451
+ return false ;
452
+ }
462
453
463
- return true ;
454
+ if ( ngModel ) {
455
+ init ( ) ;
456
+ } else {
457
+ $log . info ( 'ui.sortable: ngModel not provided!' , element ) ;
464
458
}
465
- return false ;
459
+
460
+ // Create sortable
461
+ element . sortable ( opts ) ;
462
+
463
+ // Stop Watcher
464
+ stopDisabledWatcher ( ) ;
465
+
466
+ return true ;
466
467
} ;
467
468
468
- if ( ! startIfEnabled ( ) )
469
- {
469
+ if ( ! startIfEnabled ( ) ) {
470
470
stopDisabledWatcher = scope . $watch ( 'uiSortable.disabled' , startIfEnabled ) ;
471
471
}
472
472
}
You can’t perform that action at this time.
0 commit comments