F
Filament10mo ago
TNDJXD

How to collapse section on button click

I have a livewire component that is rendering the form I want that when form is submited I collapse section I tried by passing reactive property to form livewire component but it only works on second click even though the prop got updated. Form component PHP https://gist.github.com/TNDJX/c5b730ccec35b98e02f13b8432ca1e64 From component HTML https://gist.github.com/TNDJX/275a1d39917508775a0cfa437c2f7f93 The component holding the form PHP https://gist.github.com/TNDJX/7fc1df22ea4d2836c5c78d2597e29a65 HTML https://gist.github.com/TNDJX/5cf6cf85b428e6ca1521e193104fcebf In the video you can see that it should be collapsed but form is not getting updated.
Gist
gist:c5b730ccec35b98e02f13b8432ca1e64
GitHub Gist: instantly share code, notes, and snippets.
Gist
gist:275a1d39917508775a0cfa437c2f7f93
GitHub Gist: instantly share code, notes, and snippets.
Gist
gist:7fc1df22ea4d2836c5c78d2597e29a65
GitHub Gist: instantly share code, notes, and snippets.
Gist
gist:5cf6cf85b428e6ca1521e193104fcebf
GitHub Gist: instantly share code, notes, and snippets.
3 Replies
Jon Mason
Jon Mason9mo ago
Did you ever figure out how to do this? Have a similar situation here.
LJ
LJ8mo ago
Bit late to the party, but the section has x-on:collapse-section.window so you just need to give section an ID (in my use case I settled on the ID of the record being edited) and dispatch livewire event ->dispatch('collapse-section', ['id' => $record->id])
TNDJXD
TNDJXDOP8mo ago
This worked but the definition of your dispatch is wrong it should be
->dispatch('collapse-section', id: $record->id)
->dispatch('collapse-section', id: $record->id)

Did you find this page helpful?