sortable
sortable copied to clipboard
There is a way to get only the dropped item's attributes?
When working with a lot of items in a sortable, I think that will require a lot of request in the database. So I was trying to find a way to get only the dropped item's attribute. Or a way to identify only the group that the item was dropped.
There is a way?
Thks!
Looking for the same! Could you figure out a way in the meantime? I was also thinking if there is a way to identify the dropped item in the Livewire component itself? Any ideas?
I modified the plugin method to pass in the event data to the livewire method
window.livewire.directive("sortable", (e, t, n) => {
if (t.modifiers.length > 0) return;
let o = { draggable: "[wire\\:sortable\\.item]" };
e.querySelector("[wire\\:sortable\\.handle]") && (o.handle = "[wire\\:sortable\\.handle]"),
new r(e, o).on("sortable:stop", (sortableEvent) => {
let sortableData = {
'id' : sortableEvent.dragEvent.originalSource.id,
'newIndex' : sortableEvent.newIndex,
'oldIndex' : sortableEvent.oldIndex,
};
setTimeout(() => {
let r = [];
e.querySelectorAll("[wire\\:sortable\\.item]").forEach((e, t) => {
r.push({ order: t + 1, value: e.getAttribute("wire:sortable.item") });
}),
n.call(t.method, r, sortableData);
}, 1);
});
});
You can now get information on the Groups updated and Filter only Updated groups to make the whole process easier
Refer to my post https://github.com/livewire/sortable/issues/58