Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by sandro on Nov 09, 2007 12:52
open dhtmlx forum
general drag handler for any item

Drag and drop functionality works great for widgets. I'd like to do the same with *any* element on the page.

is this possible?

for example, if i have something like this in the body:

<img src="...">

and i want the user to be able to drag that image to some target (defined with addDragLanding()), is that possible?

and: can i use the cross-frame functionality as well for this (via new dhtmlDragAndDropObject())

thanks!
Answer posted on Nov 12, 2007 03:45
Actually the used drag-n-drop functionality can be used with any custom html nodes, you can check samples

    http://dhtmlx.com/docs/products/dhtmlxTree/samples/drag_n_drop/drag_in_simple.html
    http://dhtmlx.com/docs/products/dhtmlxTree/samples/drag_n_drop/pro_drag_out.html

while both pages written around the tree, actual drag-n-drop doesn't depend on it and can be used just with pure HTML fields without tree or any other component.

to create dragable item
    dragger=new dhtmlDragAndDropObject();
    dragger.addDraggableItem(obj,dropper);

where obj - HTML done wwhic will be used as drag ( an image in your case )
    dropper - object which will control d-n-d process, you can check dhtmlxtree_dragin.js, which provides more detail.