Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] SortableJS + AlpineJS = x-for visual conflicts #2359

Open
10YAR opened this issue Mar 23, 2024 · 0 comments
Open

[bug] SortableJS + AlpineJS = x-for visual conflicts #2359

10YAR opened this issue Mar 23, 2024 · 0 comments

Comments

@10YAR
Copy link

10YAR commented Mar 23, 2024

Hello,

I'm currently struggling on using SortableJS in a AlpineJS project.
The problem is that when I drag an element, it does change the index values in the elements array, but visually, it stays the same.

This is how I init SortableJS :

document.addEventListener("DOMContentLoaded", () => {
    new Sortable(document.getElementById("sortableContainer"), {
      animation: 200,
      onStart: function (event) {
         Alpine.store("dashboard").saveOldIndex(event.oldDraggableIndex);
      },
      onEnd: function (event) {
        Alpine.store("dashboard").movePersonne(event.newDraggableIndex);
      }
    });
}); 

If you comment the Alpine.store functions, there's no bug anymore, but then the changed array isn't being saved.

Here's a codepen with the bug encountered : https://codepen.io/10YAR/pen/bGJWMxp

Thank you for your help

I tried without using a store (but a data), and it was worse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant