Permalink
Browse files

Sortable: Fix a bug of removing an item while iterating an array

  • Loading branch information...
1 parent 01e3af4 commit 4e4287faeeac420a7772ce56f15e74214c58ecea @zhizhangchen committed Sep 12, 2012
Showing with 5 additions and 6 deletions.
  1. +5 −6 ui/jquery.ui.sortable.js
@@ -562,14 +562,13 @@ $.widget("ui.sortable", $.ui.mouse, {
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++) {
- if(list[j] == this.items[i].item[0])
- this.items.splice(i,1);
+ if(list[j] == item.item[0])
+ return false;
};
-
- };
+ return true;
+ });
},

0 comments on commit 4e4287f

Please sign in to comment.