sortablejs-vue3 icon indicating copy to clipboard operation
sortablejs-vue3 copied to clipboard

Undo a sort action?

Open dilly-sixmo opened this issue 2 years ago • 1 comments

I'm using this library for sorting a list, and I'm saving the sort order server-side. I do this by listening to the end event, looping through items between event.oldIndex and event.newIndex, and performing an upsert to the database setting the order field to the new index.

This works, but what do I do if there's a network error? How can I reorder the list back to the way it was before an element was moved? I'm kind of stumped because this version of Sortable doesn't have a value/modelValue property, only a list property. And this list's order seems to be stored internally within this Sortable component. Updating the list value does nothing. I assume it's read once at initialization, and then the component handles the list internally from there. That's fine, but how can I manually change the order of elements if I want to, such as in this case?

dilly-sixmo avatar Dec 19 '22 20:12 dilly-sixmo

Would something as described here work? Otherwise I'm open to suggestions on how an API could look for your use case.

MaxLeiter avatar Dec 27 '22 20:12 MaxLeiter