vincent15000's avatar

Strange behavior with AlpineJS and the sort plugin

Hello,

In a Laravel project, with Alpine.js I'm using the sort plugin

When I drag and drop an element, I see the element move with my mouse (the element follows my mouse).

After moving a first element, when I move a 2nd one, the element I'm dragging no longer follows the mouse, but appears at the top of the screen. But once the drop is done, the items are correctly sorted.

I first thought it was perhaps a key problem, but it doesn't seem to be the problem.

What could be the reasons ?

Thanks for your help.

V

0 likes
6 replies
vincent15000's avatar

I have read some documentation / asked Lary, and then I have checked some parts of my code.

I have created a tooltip.

If I remove the tooltip, I don't have any problem while sorting items.

So the problem is that the sorted items have another div that is transformed, what partially changes the DOM, and this disturbs the sort plugin to display the ghost at the right position.

What do you suggest me to do to avoid this problem ?

jlrdw's avatar

Curious, do you need the sort plugin. Can't you just orderby (ORDER BY). I always use the database functionally for such things. But again I was just wondering. Also as you know I am old school and stay away from plugins as much as possible.

1 like
vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

Problem solved.

Hmmm ... To avoid to add manually the relative CSS property to all parents of a tooltip, I did this dynamically while the drag enter event.

I just tried to remove add / remove classList dynamically, I have added the relative CSS property manually, and now it works fine.

Please or to participate in this conversation.