droptargetContext is undefined when sortable nested
soonwait opened this issue · 5 comments
soonwait commented
Like this
<div class="grid"
data-ng-model="grid.data"
data-ui-sortable="grid.rowSortableOptions">
<div class="row"
data-ng-repeat="row in grid.data track by $index"
data-ng-model="row.cols"
data-ui-sortable="grid.colSortableOptions">
<div class="col"
data-ng-repeat="col in row.cols track by $index"
data-ng-model="col.cells"
data-ui-sortable="grid.cellSortableOptions">
<div class="cell"
data-ng-repeat="cell in col.cells track by $index">
</div>
</div>
</div>
</div>
I have fixed myself by writing 'if statement' in line 365, Like
var droptargetContext = ui.item.sortable._getElementContext(droptarget);
if(droptargetContext) {
ui.item.sortable.droptargetModel = droptargetContext.scope.ngModel;
// Cancel the sort (let ng-repeat do the sort for us)
// Don't cancel if this is the received list because it has
// already been canceled in the other list, and trying to cancel
// here will mess up the DOM.
element.sortable('cancel');
}
thgreasi commented
That's quite interesting.
Could you fork the provided nested sortable example to reproduce this, so that I can add a test case for that?
soonwait commented
OK, i have forked an example this
you should find out error in console, when drag col or row, which said:
sortable.min.js:8 Uncaught TypeError: Cannot read property 'scope' of undefined
at HTMLDivElement.C.update (https://cdnjs.cloudflare.com/ajax/libs/angular-ui-sortable/0.17.1/sortable.min.js:8:3604)
at HTMLDivElement.<anonymous> (https://cdnjs.cloudflare.com/ajax/libs/angular-ui-sortable/0.17.1/sortable.min.js:8:654)
at t.(anonymous function).(anonymous function)._trigger (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:6:11090)
at t.(anonymous function).(anonymous function)._trigger (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:13:2147)
at t.(anonymous function).(anonymous function)._trigger (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:6:4499)
at t.(anonymous function).(anonymous function).<anonymous> (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:13:869)
at t.(anonymous function).(anonymous function)._clear (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:13:1993)
at t.(anonymous function).(anonymous function)._clear (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:6:4499)
at t.(anonymous function).(anonymous function)._mouseStop (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:12:16765)
at t.(anonymous function).(anonymous function)._mouseStop (https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js:6:4499)
thgreasi commented
Releasing a fix as v0.17.2.
Thank for reporting.