Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

wants to merge 1 commit into from

2 participants


No description provided.


As mentioned in your other pull request, we need bug reports and reduced test cases before pull requests.


Problem: in some cases, iterating this.items will cause out of range problem, for example:
If you try to drag the $('.sortable.sortableItem'), there will be an error message in console:
Uncaught TypeError: Cannot read property 'item' of undefined


Should I open a bug report in ?


Thanks for the test case. If you can file a bug on that bug tracker, I'll update your commit message to reference the ticket and land your patch.


Thanks, landed in 77a4aaf. Sorry for the delay, we had to get 1.9.0 out first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 6 deletions.
  1. +5 −6 ui/jquery.ui.sortable.js
11 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;
+ });
Something went wrong with that request. Please try again.