F
Filamentβ€’2y ago
umardi_

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
Dan Harrin
Dan Harrinβ€’2y ago
no there isnt, because the sidebar is just plain Blade and not Livewire
umardi_
umardi_OPβ€’2y ago
OK then. Thank you.
Incoming
Incomingβ€’2y ago
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)
toeknee
toekneeβ€’2y ago
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
Incoming
Incomingβ€’2y ago
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 πŸ˜„
wyChoong
wyChoongβ€’2y ago
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 πŸ˜‚
Husky110
Husky110β€’2y ago
Since there are now some months passed by and I'm facing the same issue - has there been a way found by now? πŸ™‚
Patrick Boivin
Patrick Boivinβ€’2y ago
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 πŸ€“
pratik
pratikβ€’2y ago
anyone found a way around ? πŸ˜€
Want results from more Discord servers?
Add your server