Global filter...how to refresh on change though.
I want a kind of global filter. Users are allocated locations, and their resources can be filtered by locations.
I want to give users the functionality to select one or more of their permitted locations, and then for all their resources to be filtered accordingly.
So far I have worked out how to:
1) Create the filter select in the header
2) Persist this throughout the session, across the panels
3) Apply the relevant global scopes dynamically to filter everything
I am only missing one thing...which is when the select items are altered...it needs some sort of page refresh or change of resource to take effect.
How can I make it reload everything on change ?
Solution:Jump to solution
Answer:
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('locationrefresh');
})
...2 Replies
Here is some of the code:
Solution
Answer:
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('locationrefresh');
})
in a blade:
@push('scripts')
<script>
document.addEventListener('DOMContentLoaded', function () {
Livewire.on('locationrefresh', refresh => {
window.location.reload(true);
});
});
</script>
@endpush