bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
22.06k stars 1.97k forks source link

Getting the previous element in the dropped div #472

Open Neufr0 opened 7 years ago

Neufr0 commented 7 years ago

Hi

I'm new with dragula. I'm using it with meteor. The thing is, I want to save the new position of the element in MongoDB but for that I think I need to know what's the previous and the next element (their id is the id in the database) I'm using this algorithm in the first post of this issue btw https://github.com/bevacqua/dragula/issues/36

For the next element, it's easy it's just the sibling variable but for the previous one I'm stuck

When I do

sibling.previousSibling.id

it gets me the id of the element I just dropped. So I thought using:

sibling.previousSibling.previousSibling.id

but it gets me an undefined element.

Does someone have an idea ?

manuel-uberti commented 6 years ago

Anything on this? I am facing the same problem at the moment.

manuel-uberti commented 6 years ago

Nevermind, I managed to do it with el.previousSibling.