Fixing the jQuery Sortable Re-Alignment Problem

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Fixing the jQuery Sortable Re-Alignment Problem

Post 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.
User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Re: Fixing the jQuery Sortable Re-Alignment Problem

Post by volomike »

Evidently, this is a known jQuery bug:

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

...and they resolve it the same way.
Post Reply