From: John Chen Date: Wed, 12 Sep 2012 09:37:04 +0000 (+0800) Subject: Sortable: Fix a bug of removing an item while iterating an array. Fixes #8571 - Out... X-Git-Tag: 1.9.1~62 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=77a4aaf47abe08f11eb4e0eabdb2a1c026c0f221;p=jquery-ui.git Sortable: Fix a bug of removing an item while iterating an array. Fixes #8571 - Out of range problem in when dragging a nested sortable. --- diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 920e645d4..0768fdf6e 100644 --- a/ui/jquery.ui.sortable.js +++ b/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; + }); },