Emit Livewire Event from one component to a Custom Dropdown Menu to refresh nav data on save?
I have the following Component that is used for a custom dropdown navigation.
It it registered to this hook in boot:
It is used, for example, when someone updates their company name in a separate component in a form:
The following works for Jetstream, but not Filament. It isn't completely necessary but would be nice for it to update instantly after a form is saved, but as always they can refresh the browser...
11 Replies
You can render the livewire component:
Are you saying to use this instead of
$this->emit('refresh-navigation-menu');
?
Or in the render hook in the service provider?
The way the Hook is rendered is correct. The problem is that it is not updating right after a form is saved, people have to refresh the page for it to show in the dropdown navigation menu that it is updated, in the form it is updated right after but not the dropdown.. so I'm still curious as to what you mean...Did you try to debug and see if that component is actually catching an event?
Also, you are rendering only the blade file, without having any data in component, is that ok?
I will try to debug, but what do you mean? It is a navigation Menu. This is the blade file. Everything is working correct it just doesn't update when I want it to.
All right, sorry I was not aware of the file contents.
So I would:
- debug to see if the components reacts to event
- Check if the collections for Companies are cached in any way
Also, can you put something like wire:key="{{Str::random() }}"
On any div that is holding your data that needs to change
check if that changes it
Where
{{ Auth::user()->currentCompany->name }}
is? So like the button?
Oh I think I know what might be going on..
Nevermind Idk
Maybe something to do with the events being connected to Livewire while the Filament Dropdown components being connected to Filament specifically, but idk
But thank you for trying to helpIn the render hook in the service provider. Try to change it.
I did it didn’t do anything, actually just slowed down the request
*it still worked but slowed down request time after form submitted for some reason, problem is still present tho
Hum. Understood
GitHub
filament-companies/update-company-name-form.blade.php at 1.x · andr...
Contribute to andrewdwallo/filament-companies development by creating an account on GitHub.
This is the update company name blade file though if it helps anyone who comes across this and wants to help, maybe I am doing something wrong here
Although I’ve always had problems with emitting events specifically in Filament, not dispatching a browser event tho
If I do wire:click the event name from the button on submitting it doesn’t submit or anything
Thank you again for trying to help!