From 77a4aaf47abe08f11eb4e0eabdb2a1c026c0f221 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 12 Sep 2012 17:37:04 +0800 Subject: [PATCH] Sortable: Fix a bug of removing an item while iterating an array. Fixes #8571 - Out of range problem in when dragging a nested sortable. --- ui/jquery.ui.sortable.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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; + }); }, -- 2.39.5