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

Commit 6991b9f

Browse files
author
michaschwab
committed
moved starting code into a new function, and cancelling watcher if start function is called.
1 parent d4d1558 commit 6991b9f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/sortable.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,27 @@ angular.module('ui.sortable', [])
448448
$log.info('ui.sortable: ngModel not provided!', element);
449449
}
450450

451-
var created = false;
452-
scope.$watch('uiSortable.disabled', function()
451+
var listener = function() {};
452+
453+
var startIfEnabled = function()
453454
{
454-
if(!created && !scope.uiSortable.disabled)
455+
if(!scope.uiSortable.disabled)
455456
{
456-
created = true;
457-
458457
// Create sortable
459458
element.sortable(opts);
459+
460+
// Stop Watcher
461+
listener();
462+
463+
return true;
460464
}
461-
});
465+
return false;
466+
};
467+
468+
if(!startIfEnabled())
469+
{
470+
listener = scope.$watch('uiSortable.disabled', startIfEnabled);
471+
}
462472
}
463473
};
464474
}

0 commit comments

Comments
 (0)