J
Joel Byrd
I'm trying to accomplish the following: I want to set up generic
drag-drop functionality for dragging and dropping images. I want to be
able to drag various images into various drop targets, and when they
are dropped, they should call a function that I've defined.
I searched the internet for a tool that could accomplish my goal easily
and effectively, and I found 2. Yahoo! UI Library and Walter Zorn's
wz_dragdrop. At first, the Yahoo! UI Library looked great, but as I
proceeded to download it and try to implement it, I found it was not
idiot-proof - I had trouble implementing it, so I looked to Walter
Zorn's wz_dragdrop. The ease with which this tool implemented and the
incredible functionality offered by it was like magic. But now, I've
run into sort of a dead-end.
I've gotten as far as being able to drag images (so that the original
image stays put while a transparent copy is dragged) and when I drop
them, they float back to their original position. So, I've pretty much
got the whole "drag" part down, but I'm having trouble with the "drop"
part. One of the functions included in wz_dragdrop is called
"my_DropFunc()" - this is called any time a draggable object is
dropped, and within the function, you have access to a just about any
property of the dragged object, as well as some methods of the dragged
object - one in particular called "getEltBelow()", which gets the
element below the draggable object - and this would be perfect, because
once I've identified the object below the draggable object, I can
determine whether it is a drop target, and if so call some function to,
say, do some ajax, and then make the image disappear. The problem is
that the getEltBelow() function is not working cross-browser. It works
fine in IE and Firefox, but is way off in Opera.
An example of my code is located at:
http://web.njit.edu/~jmb2/Joel/temp.javascript_test.php
In IE and Firefox, if you drag one of the images over one of the
folders, and then drop it, an alert will display the id of the drop
target below the dragged image. In Opera, it's off - you'll notice,
for example, that if you drop an image over the folder "droppable_0",
it will think that the object below the dragged image is actually
"droppable_2".
I've tossed around the idea of starting from scratch with the Yahoo! UI
Library, since it would be more flexible, but wz_dragdrop offers so
much functionality that can be implemented so easily, and I'm so close
to getting this thing to work. I've looked on the web and seen almost
no one implementing drag *and* drop functionality with Walter Zorn's
script. If anyone has any ideas as to my problem, or can point me to
an exmple of implementing drag-drop with wz_dragdrop, let me know.
Joel
P.S. Another little bug I noticed is that in IE, _sometimes_ the copied
image loads much smaller than the original image, which has a negative
effect both visually and functionally.
drag-drop functionality for dragging and dropping images. I want to be
able to drag various images into various drop targets, and when they
are dropped, they should call a function that I've defined.
I searched the internet for a tool that could accomplish my goal easily
and effectively, and I found 2. Yahoo! UI Library and Walter Zorn's
wz_dragdrop. At first, the Yahoo! UI Library looked great, but as I
proceeded to download it and try to implement it, I found it was not
idiot-proof - I had trouble implementing it, so I looked to Walter
Zorn's wz_dragdrop. The ease with which this tool implemented and the
incredible functionality offered by it was like magic. But now, I've
run into sort of a dead-end.
I've gotten as far as being able to drag images (so that the original
image stays put while a transparent copy is dragged) and when I drop
them, they float back to their original position. So, I've pretty much
got the whole "drag" part down, but I'm having trouble with the "drop"
part. One of the functions included in wz_dragdrop is called
"my_DropFunc()" - this is called any time a draggable object is
dropped, and within the function, you have access to a just about any
property of the dragged object, as well as some methods of the dragged
object - one in particular called "getEltBelow()", which gets the
element below the draggable object - and this would be perfect, because
once I've identified the object below the draggable object, I can
determine whether it is a drop target, and if so call some function to,
say, do some ajax, and then make the image disappear. The problem is
that the getEltBelow() function is not working cross-browser. It works
fine in IE and Firefox, but is way off in Opera.
An example of my code is located at:
http://web.njit.edu/~jmb2/Joel/temp.javascript_test.php
In IE and Firefox, if you drag one of the images over one of the
folders, and then drop it, an alert will display the id of the drop
target below the dragged image. In Opera, it's off - you'll notice,
for example, that if you drop an image over the folder "droppable_0",
it will think that the object below the dragged image is actually
"droppable_2".
I've tossed around the idea of starting from scratch with the Yahoo! UI
Library, since it would be more flexible, but wz_dragdrop offers so
much functionality that can be implemented so easily, and I'm so close
to getting this thing to work. I've looked on the web and seen almost
no one implementing drag *and* drop functionality with Walter Zorn's
script. If anyone has any ideas as to my problem, or can point me to
an exmple of implementing drag-drop with wz_dragdrop, let me know.
Joel
P.S. Another little bug I noticed is that in IE, _sometimes_ the copied
image loads much smaller than the original image, which has a negative
effect both visually and functionally.