Open aeruggiero opened 9 months ago
You can pass the onEnd
event to VueDraggable
and obtain element information from the event object.
<template>
<VueDraggable
v-model="statusOrders[index]"
:animation="150"
ghostClass="ghost"
group="people"
:key="status.id"
:id="'status' + index"
tag="div"
@end="onEnd"
>
<div
v-for="item in statusOrders[index]"
:key="item.id"
class="cursor-move h-30 bg-gray-500/5 rounded p-3"
@dragend="handleDrag(item)"
>
{{ item.code }}
</div>
</VueDraggable>
</template>
<script setup>
function onEnd(e){
console.log(e)
}
</script>
Hi all, I've been looking everywhere but it seems not possible to get info regarding the item being dragged, the source and the destination at the same time. I have a situation like this:
As you can see, I need to update the order status depending on where I drag the item. If I had the target div ID, I would be able to immediately retrieve the corresponding status. However, currently, the only way is to loop through the array and check for the dragged item. Additionally, the only way I can obtain the item is by using the 'ondragend' event on the dragged item.
Do you have any suggestions? Am I doing something wrong?
Thanks