jQuery UI's droppable API manual mentions how to get the "dropped-on-droppable" very "secretly" in the section of greedy option:
event.target
can be checked to see which droppable received the
draggable element
But note that event.target
contains just a DOM element...
Answer to your question
You will be able to get the ID in your droppable
's drop
callback through the first parameter event
.
Pure JS
Property: event.target.id
- if ID is not set: empty string ""
Attribute: event.target.getAttribute('id')
- if ID is not set: null
jQuery
Property: $(event.target).prop('id')
- if ID is not set: empty string ""
Attribute: $(event.target).attr('id')
- if ID is not set: undefined
Usage example
<script>
$(function(){
$(".droppablesSelector").droppable({
drop: function (event, ui) {
//display the ID in the console log:
console.log( event.target.id );
}
});
});
</script>
Additional info
Event
jQuery's event system normalizes the event object according to W3C standards.
The event object is guaranteed to be
passed to the event handler (no checks for window.event required). It
normalizes the target, relatedTarget, which, metaKey and pageX/Y
properties and provides both stopPropagation() and preventDefault()
methods.