How to get new group/status of dragged item in x-sort? #4619
-
|
Using x-sort with groups — how can I get the new group/status (like todo, pending, etc.) of the dragged item after it's dropped into a new list? Can't figure it out code: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
🧩 Alpine.js Drag & Drop in Livewire — Fixing group not giving column key ✅ Problem: ✅ Solution: 💡 Final Working Code |
Beta Was this translation helpful? Give feedback.
🧩 Alpine.js Drag & Drop in Livewire — Fixing group not giving column key
After two full days of debugging, here's the working solution to get the actual column key (like "TODO", "IN_PROGRESS", etc.) when sorting tasks with Alpine's x-sort.
✅ Problem:
Alpine’s x-sort:group="tasks" just gives a group name ("tasks") — not the specific column key from your data (e.g., TODO, DONE).
You want to know which column the task was dropped into.
✅ Solution:
Use a data-status="{{ $key }}" on the column container, and grab it via closest('[data-status]') in your Alpine handle() function.
💡 Final Working Code
blade