This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-18
lines changed
Expand file tree Collapse file tree 1 file changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -444,30 +444,36 @@ angular.module('ui.sortable', [])
444444 patchUISortableOptions ( opts ) ;
445445 }
446446
447- function watchOnce ( watchExpr , fn ) {
448- var cancelWatcher = scope . $watch ( watchExpr , function ( ) {
449- fn . apply ( this , arguments ) ;
450- cancelWatcher ( ) ;
451- } ) ;
447+ function init ( ) {
448+ if ( ngModel ) {
449+ wireUp ( ) ;
450+ } else {
451+ $log . info ( 'ui.sortable: ngModel not provided!' , element ) ;
452+ }
453+
454+ // Create sortable
455+ element . sortable ( opts ) ;
452456 }
453457
454- function lazyInit ( ) {
458+ function initIfEnabled ( ) {
455459 if ( scope . uiSortable && scope . uiSortable . disabled ) {
456- watchOnce ( 'uiSortable.disabled' , lazyInit ) ;
457- } else {
458-
459- if ( ngModel ) {
460- wireUp ( ) ;
461- } else {
462- $log . info ( 'ui.sortable: ngModel not provided!' , element ) ;
463- }
464-
465- // Create sortable
466- element . sortable ( opts ) ;
460+ return false ;
467461 }
462+
463+ init ( ) ;
464+
465+ // Stop Watcher
466+ initIfEnabled . cancelWatcher ( ) ;
467+ initIfEnabled . cancelWatcher = angular . noop ;
468+
469+ return true ;
468470 }
469471
470- lazyInit ( ) ;
472+ initIfEnabled . cancelWatcher = angular . noop ;
473+
474+ if ( ! initIfEnabled ( ) ) {
475+ initIfEnabled . cancelWatcher = scope . $watch ( 'uiSortable.disabled' , initIfEnabled ) ;
476+ }
471477 }
472478 } ;
473479 }
You can’t perform that action at this time.
0 commit comments