Sortable: Fix a bug of removing an item while iterating an array. Fixes #8571 - Out of range problem in when dragging a nested sortable.

This commit is contained in:
John Chen 2012-09-12 17:37:04 +08:00 committed by Scott González
parent a3f1a34d3b
commit 77a4aaf47a

View File

@ -562,14 +562,13 @@ $.widget("ui.sortable", $.ui.mouse, {
var list = this.currentItem.find(":data(" + this.widgetName + "-item)"); var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
for (var i=0; i < this.items.length; i++) { this.items = $.grep(this.items, function (item) {
for (var j=0; j < list.length; j++) { for (var j=0; j < list.length; j++) {
if(list[j] == this.items[i].item[0]) if(list[j] == item.item[0])
this.items.splice(i,1); return false;
}; };
return true;
}; });
}, },