Page 1 of 1

Fixing the jQuery Sortable Re-Alignment Problem

Posted: Wed Nov 26, 2008 2:53 pm
by volomike
You may encounter a problem with jQuery when you use the UI .sortable() method to create a drag and drop sortable list on your UL or OL items. What happens is if you drag and drop items slightly on top of another one, and then very rapidly keep trying to unclick and click another item, the items will get stacked on top of each other, which isn't supposed to happen. I was getting this problem on FF2 (Windows only) and IE (any version). But when I worked on Ubuntu with FF3, I didn't have this problem.

I tracked this down to the fact that I was using the 'revert: true' property when building my sortable, like so:

Code: Select all

$('#layout-items').sortable({
  items: '.movable',
  cursor: 'move',
  opacity: 0.7,
  scroll: true,
  axis: 'y',
  revert: true,
  containment: $('#layout-items')
});
 
Once I took that 'revert: true' property out, the problem went away. So, it looks like it's a jQuery bug on my version of jQuery (1.2.6).

Hope this suggestion helps you.

Re: Fixing the jQuery Sortable Re-Alignment Problem

Posted: Wed Nov 26, 2008 3:05 pm
by volomike
Evidently, this is a known jQuery bug:

http://dev.jquery.com/ticket/2780

...and they resolve it the same way.