Peter Michaux wrote:
On Aug 16, 4:35 pm, Jeff <jeff@spam_me_not.comwrote:
> Somewhere I've seen a list that is drag and drop sortable, where you
can "grab" a list item and move it up or down the list.
Can someone summarize how this is done. I really don't want to hack
my way through something like scriptaculous.
1) mousedown event
determine the target element in list
record mouse position
2) mousemove event
determine relative position of mouse to starting position on
mousedown
move the target element visually (position:relative helps)
I'm having trouble here:
simplified example
document.onmousedown=mouseDown;
function mouseDown(e){
e = e || window.event;
target=e.target || e.srcElement;
if(target.nodeName == 'LI'){
target.position = 'relative';
target.style.top = '400px';
// li does not move
}
Yet, this "works":
<li style="position: relative;top: 400px">this is offset</li>
What have I missed? Doctype is strict.
Jeff
3) mouseup event
move the element in the DOM to its new position in the list
>
Peter