SPresnac's avatar

Rerender JavaScript stuff on page after search or pagination

Hej, i do have a list of People that is paginated (by 12, just for saying). Every one has a button right beside the name with a flux:modal (but the problem is the same with other js stuff, just as example).

So, on the first page, all works well. But when changing the page or searching someone who was not initially in the list of the first 12, the modal will not open. I am suggesting, that the reason is, that the modal is not in the browsers DOM yet.

So, example: User 13 is not in the inital 12, you change page to 2. A click on the modal button will not work. A reload of the page 2 and you can open the modal then (cause it is in the dom now).

Anything I can do? Newest Livewire, newest Laravel, newest vendor package all along. Livewire class is using "WithPagination" and has a

    public function updatingSearch()
    {
        $this->resetPage();
    }

I have no idea how to solve this one...

--- 2025-10-20: Edit to paste some code I use ---------------------------------

The route goes to Participants::index() , this returns a blade view participants.index that includes some UI and also this line

@livewire('participants.index', ['employers' => $employers])

This is the Participants.Index.php (the Livewire Controller)

and here is the livewire.participants.index (the livewire view)

I do know, this is not the best solution and I am open to any suggestions.

0 likes
3 replies
valentin_vranic's avatar

Hey. I'm not so familiar with flux behaviors and components. However I don't recommend to render unnecessary view for each row, rather define one on bottom of parent page, something like let's say:

<x-dialog wire:show="clickedPerson">
    <x-dialog.panel panelWidth="w-50">
        @if($clickedPerson)
            @include('livewire.person', ['person' => $clickedPerson])
        @endif
    </x-dialog.panel>
</x-dialog>

This is my custom livewire panel case. So in each row to have a button, with wire:click="loadPerson($id)" which will trigger a method, and that will load the person by id.

Something like this, so in this case, it will be dependent on the provided $id rather than the loaded view.

SPresnac's avatar

I did update my origin post and added some code, hope it helps...

SPresnac's avatar

Thank you @rihulfaakbar , this is the solution to my problem. Thanks a lot for it. wire:key is making it happen.

Please or to participate in this conversation.