NavigationBadge count number refresh/poll automatically
Hi everyone, is there a way (built-in way) to make the count number of a badge at sidebar refresh/polls when there is update, without manually refreshing whole page? I can't find it on the documentation page. Thank you all.
9 Replies
no there isnt, because the sidebar is just plain Blade and not Livewire
OK then. Thank you.
I have the exact same issue, the polling do not refresh the navigation count which makes it desync with the data display in the table. @Umardi Did you find anyway to overcome this problem even with pure JS? (that would involves to create new routes I suppose)
You would need to add a watcher and emit an event on updating so the badge watcher can refresh the content when there is a change
Not sure how this will work as @Dan Harrin said the sidebar is just Blade, still need to query this number from a route and dont even know how to call the getNavigationBadge directly, as this is protected may need to create another public method to get it from another route - not seeing the full picture yet π
Maybe, just maybe, you can hack around it.
Since out of the box the navigation item doesnβt have class hook or reference for js to query, you can query the navigation items using js, then loop thru it
Hook a livewire class with listener using render hook. And use
invade
to get around the protected method and call getNavigationLabel and getNavigationBadge, return a json with label:badge key pair for the js to loop and replace
Not tested and you on your own πSince there are now some months passed by and I'm facing the same issue - has there been a way found by now? π
Neither
label
nor badge
support HtmlString
so there is no straightforward way to add Alpine.js expressions in navigation items
I think this could be an easy PR if you're interested π€anyone found a way around ? π