Is there any particular reason why you are using JS to add a new menu item rather than using livewire ?
If you really want to use JS, you should use AlpineJS rather than jQuery.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've a Livewire component for a side-menu. When I add a new menu-item I need the side-menu to refresh, but it doesn't. Instead, I've to reload the page to see the new item. Can you please help. Thanks
Adding a new menu-item | no errors
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: link,
method: "GET",
success: function(ret) {
var lw_sidebar= Livewire.getByName("side-menu")[0];
lw_sidebar.$refresh();
...
resources\views\livewire\side-menu.blade.php
@foreach ( $proj02 as $proj )
<li class="nav-item">
<a href="#" class="nav-link" id="{{$proj02[0]->app}}-{{$proj->id}}">
<i class='fas fa-trash-alt nav-icon'></i>
<p>{{$proj->pname}}</p>
</a>
</li>
@endforeach
class SideMenu:
public function render() {
return view('livewire.side-menu', [ ...]);
}
stt.blade.php | View
<aside class="main-sidebar sidebar-dark-primary elevation-4" style="top: 0; bottom:0; position:fixed ">
@livewire ("side-menu",[ ... ]);
</aside>
Please or to participate in this conversation.