Force update to sidebar navigation
I'm trying to implement "pinning" navigation items so that they appear at the top of a user's sidebar and are eventually draggable to sort.
My
PinPage
action that adds/removes pages from the user table is working dynamically, so that the label immediately updates from "Pin" to "Unpin", but I currently have to refresh the browser to see the navigation update. I was hoping SPA mode would magically work, but that still requires a navigation to update.
Any ideas? Is there some Livewire component I can force to refresh/re-render?4 Replies
My panel provider:
Unfortunately, the sidebar / navigation isn’t a Livewire component so there’s no built in listeners. I think the only solution is to force a page reload.
Okay, I guess that's not surprising since I'm sure it would have magically just worked otherwise 🙂
If I'm planning on customizing the sidebar blade to add
x-sortable
support, I suppose an Alpine-oriented approach might work? Or, once SPA mode is working for me (https://github.com/livewire/livewire/pull/9059) a page reload could be virtually unnoticeable.
Oh, it seems like Livewire Navigate may work even if the panel is NOT in spa mode. If I add $livewire->js('Livewire.navigate(window.location.href);');
to the end of my action (with injected $livewire
) it works just as intended. Cool!Yea. There’s multiple ways to reload a page. Glad you got it working.