Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vernon Blackmore on Sep 16, 2009 05:52
open dhtmlx forum
Drag and drop icon triggers event?

I'm dragging on icon on to a tree to indicate the addition of a new file. The icon is external to the tree. The icon drops into the tree just fine and shows as an icon in the tree but without itemText. What I'd like to do is have this trigger an event, so that I can prompt the user for a file name at the point of dropping the icon. At the moment I have to wait for the user to click on the icon and use the onClick event to detect there is no itemText and so trigger a request for content.

I have an onDrag handler set up - and this triggers fine when dragging existing nodes around. But it is not triggered by the addition of an icon dragged from outside the tree.

Thanks.
Answer posted by Alex (support) on Sep 16, 2009 10:03

You can use makeDragable in this case:

tree.makeDragable("a2",function(drop_obj,source_id,target_on,target_before){
  var item_text = prompt("Please enter item text");
  drop_obj.insertNewItem(target_on,source_id,item_text);
});

Please, see sample in the tree package dhtmlxTree/samples/05_drag_n_drop/01_drag_in_simple.html