Scriptaculous Sortables: Dynamically adding a new li in the onUpdate Callback

Edward Trochim
Thu, 08 Mar 2007 00:22:17 -0000

I have two sortable lists that I can drag elements between, list A and
list B. When I drag an element from A to B I want to be able to
dynamically create a new element in A. I can do that just fine and
call Sortable.create again for A and B to make the new element
draggable.

However, this is where the problem is. The two Sortable.create calls
are taking place inside the onUpdate callback. So before the dragged
element has settled into place in B Sortable.create has already been
called on B. There isn''t a problem immediately but when I attempt to
reorder the elements in B there will often be random displacements of
the element being dragged around. This only happens when I call
Sortable.create on list B (which it seems I need to do because if I
don''t then after I call Sortable.create on list A I can no longer drag
elements in list B). How can I fix this issue?

Here is a screenshot showing the problem (list A on the left, list B
on the right): http://paradox.mynuts.org/problem.png