Hi,
I want to do some custom logic on items being dragged and dropped - I need an
event callback that has a reference to both the element being dropped (the LI),
and the target element that it''s being dropped onto (the UL).
I''ve found the
Sortables.create option for creating an onUpdate and onChange handler, and done
the following:
function selectItem(target){
window.status=target.id;
}
window.onload=function(){
Sortable.create("firstlist",{tag:''div'',containment:["firstlist","secondlist","firstCell","secondCell"]});
Sortable.create("secondlist",
{ tag:''div'',
containment:["firstlist","secondlist","firstCell","secondCell"],
onUpdate:selectItem
}
);
}
I set a breakpoint in selectItem, and play with the two lists. selectItem() gets
called whenever an item is dropped onto the list, with a single argument being
the UL that it''s being dropped on to. Inside the callback,
''this'' refers to an
object that also holds a ref to the UL, and a string called
''lastValue'' with a
value of
"secondlist[]=undefined&secondlist[]=undefined&secondlist[]=undefined&secondlist[]=undefined&secondlist[]=undefined&secondlist[]=firstlist2&secondlist[]=undefined"
which I won''t pretend to understand :-)
How do I get a ref to the item being dropped? (I had a look at the onChange
handler too, it looked hopeful from the code. I set up a similar dummy handler
function, but it doesn''t seem to get invoked when I''m working
on the list...)
Many thanks,
Dave
--
Dave Crane
author ''Ajax in Action'' http://www.manning.com/books/crane
http://dave.sunwheeltech.com/wordpress/