Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Cory Nelson on Mar 20, 2008 12:14
open dhtmlx forum
onDrop

Is there anyway to check an ondrop event within a function? Here's what I'm trying to do. I have two trees where I'm dragging a multiselected list from one to the other. As such, when I drop the list of items I need to check each one in order to see if dropping it there is valid (it's important that if one fails the rest are still checked on their own).

I've tried using onDrop but by the time it triggers the items is already dropped. From there I tried deleting it but I don't have any control it seems of figuring out the name of the new item(s) (I can guess but it isn't always correct).

I'm currently using onDragIn which works mostly. I'm able to drop create a new object when it's valid and ignore it when it's not. The problem is that since it's constantly running it can potentialy find multiple locations where it's valid (In my case the objects being dropped just don't want duplicates in the children, but they can duplicate themselves multiple times in trees). Effectively if I take the item and drag it all around the tree I get multiple of that item in various places in the list. This is a valid solution but I only want to drop once when I'm actually adding them ideally.

What I think I want to do is keep my onDragIn and then do a secondary check that says not to actually create the new object until the user has taken his mouse off the cursor. Thoughts?
Answer posted by Support on Mar 21, 2008 02:38
While d-n-d next event generated

onDragIn - item draged over landing
onDrag - item draged over landing, mouse button released
onDrop - item droped, all operations in tree done

First two events - blockable - so you can prevent operation by returning false from event handler.

>> The problem is that since it's constantly running
As far as I can see - you can use onDrag instead of onDragIn - it occurs only once, when  mouse released, but it occurs before real operations in tree - so you can block default behavior if necessary.