Nested sortables with Livewire event handling
juliomotol opened this issue · 16 comments
Is there any way I could handle the wire:onSortOrderChange
and know whether it has been move from one list to another?
I think my problem is related.
I need at least the group in the handleSortOrderChange method, or another customizable parameter.
Same problem here, right now theres no way to know in what dropzone you dragged your items. @asantibanez
Hi all! Thanks for your interest in the package.
This issue has been addressed in v1.1.0.
wire:onSortOrderChange
gets called on any interaction with the drop zone: sorting, adding, removing.
Check it out.
I still don't understand how that update fix this ?
Maybe I'm missing something.
Don't follow @SquareBeard . Inside your Livewire component you have 2 drop zones and want to get updated on both with wire:onSortOrderChange
?
Sorry maybe I should have done another issue, it does not seem related anymore.
I want to know which drop zone is calling onSortOrderChange.
My drop zones are created dynamically, I can't use a different method for each zone. I just need the group name or some other parameter to identify the drop zone.
Something like
function handleSortOrderChange($order, $groupName) { ... }
Does that make more sense ?
I'm sorry @asantibanez, I'm with @SquareBeard on this one.
The concern was:
Is there any way I could handle the wire:onSortOrderChange and know whether it has been move from one list to another?
And yet, the new release feels like a refactor rather than a fix.
Taking an inspiration from SortableJs' event parameters, we could do:
function handleSortOrderChange($order, $toGroup, $fromGroup) { ... }
This is doable. How would you identify the containers? With an id in the sortable component?
Sounds good, but 'from' before 'to' feels more natural to me.
function handleSortOrderChange($order, $from, $to) { ... }
Hey @SquareBeard @juliomotol
Have this one working. I am sending this info the Livewire component:
Example callback
Demo
How's that looking?
@asantibanez Looking like a charm. I really loved that you included the old sort order. Might come handy in the future.
Resolved in v1.2.0 👍
https://github.com/asantibanez/laravel-blade-sortable/releases/tag/v1.2.0
Looks great, thank you.
Hello and thank you for creating this!
About the demo above. When you move "Andres" to the middle section. How I should get the data that "Andres" was moved to somewhere?
I was hoping the "name" param would show this..
I think the only way to get this data now is to compare sortOrder and previousSortOrder and remove duplicates