I Have div
included in another parent div
that are both allowed for "drop".
In the example a class named "red" is added to all droppable object in dragenter
event. So if I enter the mouse durring drag in child element both child and parent will get "red" class.
When I abort the drag&drop or if I leave elements during operation, the dragleave
event will remove the added "red" class.
The problem is when I drop the element into child there are two options :
drop
eventThe problem is that in this case, the parent won't execute the
drop
event and the "red" class will not be removed at all in parent.
drop
eventThe problem is that in this case the
drop
event will be executed for both child and parent element. But the drop action should be done only for child element.
I thought about a solution using stopPropagation() by runing through event.path
array for removing the added class but there are probably another ways to solve the problem.
Here the fiddler for option 1 with stopPropagation()
Here the fiddler for option 2 without stopPropagation()