Including a Livewire component inside an Infolist

Hi, I try to render a small Livewire component inside an Infolist modal. It renders when using ViewEntry component, but when I call a method from the Livewire component, it fails with the error
Unable to call component method. Public method [confirmLoginLink] not found on component
The component is supposed to start some background stuff and then update when a model instance is changed. ViewEntry
Infolists\Components\ViewEntry::make('get_login_link')
->view('livewire.get-login-link', ['site' => $infolist->record->site]),
Infolists\Components\ViewEntry::make('get_login_link')
->view('livewire.get-login-link', ['site' => $infolist->record->site]),
Livewire template
<button type="submit" wire:click="confirmLoginLink({{ $site->id }})">
Click me
</button>
<button type="submit" wire:click="confirmLoginLink({{ $site->id }})">
Click me
</button>
I suspect that I'm using the wrong approach here, and would appreciate if someone could point me in the right direction.
4 Replies
Patrick Boivin
Patrick Boivin16mo ago
Hi @hgrimelid, can you share the complete template (the main component that includes the other component)? I suspect the wire:click is not calling the method in the right scope.
hgrimelid
hgrimelidOP16mo ago
@Patrick Boivin I reference the Livewire template (the one shown above) directly from the infolist method in the resource class. I don't have any other templates.
Patrick Boivin
Patrick Boivin16mo ago
Ok, I'm not sure it's the right approach, but you're not far. I think you need to include a regular Blade view in ->view(), and then inside of that view, render your Livewire component.
hgrimelid
hgrimelidOP16mo ago
@Patrick Boivin That worked! Thank you, appreciated!
Want results from more Discord servers?
Add your server