When a sortable has ''ghosting'' enabled, it seems to include the dragged element twice in the list which is submitted in the onUpdate AJAX request. By the looks of it, it''s appended onto the end of the list when Sortable.serialize is called. IE in the following list: - 1 - 2 - 3 If I drag 3 to be at the top, what we expect is: [3, 1, 2] What we get is: [3, 1, 2, 3] I''ve not been able to quite work out why this is yet. At the moment, workarounds are: - don''t use ghosting - ignore the last element received - call #uniq on the array received Thanks. If I get time I''ll try and dig a bit deeper, but I''m currently getting the house ready for people coming round tomorrow so no promises! -- R.Livsey http://livsey.org
Richard & List,> When a sortable has ''ghosting'' enabled, it seems to include the dragged > element twice in the list which is submitted in the onUpdate AJAX request.I''ve ran into this problem as well.> By the looks of it, it''s appended onto the end of the list when > Sortable.serialize is called.Not quite. What happens is serialize calls childNodes on the passed element... Unfortunately childNodes includes the cloned element. So what is actually happening is it is including the cloned element, not just arbitrarily adding one at the end. IE: (moving element 2 to the end of the list) pre-dragging list 1 2 3 when you start 1 2clone 2 3 when Draggables.notify is called... 1 2clone 3 2 when its all over 1 3 2 (end of example) couple ways of solving this. 1) move the clone removing code above the notifications 2) move the clone removing code above the this.observer call in onEnd 3) add this._clone.ghost = true; after the cloneNode creation, and !items[i].ghost in the serialize condition and the findElements condition 4) 1 and 3 5) 2 and 3 Discussion of the best solution follows? -Caleb