This repository was archived by the owner on Sep 8, 2020. It is now read-only.
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Error: no such method 'refresh' for sortable widget instance #313
Description
I occasionally get this error. The culprit appears to be the following:
// When we add or remove elements, we need the sortable to 'refresh'
// so it can find the new/removed elements.
scope.$watch(attrs.ngModel+'.length', function() {
// Timeout to let ng-repeat modify the DOM
$timeout(function() {
// ensure that the jquery-ui-sortable widget instance
// is still bound to the directive's element
if (!!element.data('ui-sortable')) {
element.sortable('refresh');
}
}, 0, false);
});
Specifically, the check if (!!element.data('ui-sortable'))
seems to be incorrect.
I initialize my ui-sortable as follows:
<ul
data-ui-sortable="sortableOptions"
data-ng-model="myModel">
</ul>
The check to see if the sortable instance is initialized normally returns a jQuery $.widget
object, but in the cases where I get this error, it is just returning the string sortableOptions
so it appears the check is occurring prior to the Angular compilation but still resulting in true because a string value is truthy. Of course, refresh
cannot be called on an uninitialized sortable leading to this exception.
Metadata
Metadata
Assignees
Labels
No labels