Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag & Drop with nested target in HTML5

I'm using HTML5 drag&drop; I have a droppable div and inside it I have another droppable div.

<div id="target-parent">
    <div id="target-child"></div>
</div>

The problem is that if I drag something into the target-child, fire his drop event (and this is right) but in the end fire also the target-parent event. How can the code understand that the dropped element is only target-child?

like image 915
Nicola Avatar asked Jun 28 '13 15:06

Nicola


1 Answers

In your event handler examine the event.target and behave appropriately and/or call event.stopPropagation().

like image 97
robertc Avatar answered Oct 07 '22 06:10

robertc