]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: Fix a bug of removing an item while iterating an array. Fixes #8571 - Out...
authorJohn Chen <zhang.z.chen@intel.com>
Wed, 12 Sep 2012 09:37:04 +0000 (17:37 +0800)
committerScott González <scott.gonzalez@gmail.com>
Wed, 10 Oct 2012 18:39:38 +0000 (14:39 -0400)
ui/jquery.ui.sortable.js

index 920e645d4cecbaa0d00dbb378ee12174b878b7f5..0768fdf6e6428dbf16a15ebd3b34d9a6eed64b66 100644 (file)
@@ -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;
+               });
 
        },