Can you show the full code for @livewire ("side-menu",[ .. ]); ?
Jul 10, 2024
5
Level 2
Livewire | $refresh doesn't work
My livewire component works fine when the page loads, then I add a new menu via ajax call, but when I click on the refresh button, the component doesn't refresh and I've to reload the page to see the changes. No error messages. Thanks
- Laravel 11
- Livewire 3
- Vite 5 - I think the issue is here ***
resources\views\livewire\side-menu.blade.php
<div class="sidebar" >
<button x-on:click="$wire.$refresh()" class="d-block btn btn-primary" >Refresh </button>
I also tried:
<div class="sidebar" >
<button wire:click="$refresh()" class="d-block btn btn-primary" >Refresh </button>
sidemenu.blade.php
<aside class="main-sidebar sidebar-dark-primary elevation-4" style="top: 0; bottom:0; position:fixed ">
<a href="/home" class="brand-link"> </a>
@livewire ("side-menu",[ .. ]);
</aside>
...
https://livewire.laravel.com/docs/actions#refreshing-a-component
Level 2
Sorry my mistake. I found the issue in the Controller (blade) - the logic was wrong and the controller didn't get the new data from the table. Livewire $refresh works fine now. Thank you.
1 like
Please or to participate in this conversation.