How can I refresh the page after a filter is changed
Hey all, I am currently looking for a way to refresh the whole page whenever a filter of a table is changed. The reason for this is that I have a widget with a mapping tool. And whenever the filter is changed I want it to change map. The problem is that the map of this mapping tool, can not be changed unless the page is reloaded.
These are my current filters:
Preferably it only refreshes the page when the transmitters filter gets changed, but I won't mind if there is a solution where it happens if either one gets updated.
7 Replies
Hi Tjiel,
I had similar problem try to inject current livewire component to your filter closures then do
$livewire->dispatch('eventName')
Remember to register listener in your component and pass it $refresh
like this:
Thanks for the responses I've currently added an action to the filters:
This action is running whenever a filter gets changed (like how I wanted it). The problem with the dispatch and then refreshing the livewire component is that for some reason the maping tool can't have multiple instances on the same page. Even if you delete/remove the previous one.
So basicly I need a way to reload the page and then set the map url in the getFooterwidgets using the parameters of the filter.
Here is how the data is passed in the getFooterWidgets:
You could reach for laravel redirect method maybe something like this:
Update:
I just found a solution using livewire dispatch:
and then have a listener in the mapplicWidget like this:
And lastly have a livewire.on in the blade file:
now i only need to find out how to get the filters inside the getFooterWidget
Great glad that you have sorted it out thats roughly what i meant with using listeners:)
Yeah ty for that at first I didn't think about that but then i was thinking adding custom js and circled back to the dispatch you brought up