Calling Action Modal from parent livewire component
Hi, I'm having a "card" livewire component that's inside a loop from the parent component. The card component has a delete action with confirmation.
The docs say the <x-filament-actions::modals /> needs to be in the same component as the action and that's true. However, if I do it like this, a modal gets rendered for each card, instead of just having one.
Is there any better solution for this? Like calling the modal from the parent?
Solution:Jump to solution
Technically it’s not wrong to have it in each card. What exactly is happening. Is it showing multiple modals when you click the button?
6 Replies
You only need that in one place. It should be in your parent livewire component.
If I place it in the parent, the model doesn't show up (also, no JS error). It only shows up, if it's inside the card component
Solution
Technically it’s not wrong to have it in each card. What exactly is happening. Is it showing multiple modals when you click the button?
it seems to work fine. I was just wondering, because I read on the filament website that modals inside the panel are reusable, so I was confused, why it doesn't work that way.
They are reusable. They just don’t use one ‘modal’ in the html. In the context of reusable for this it means you can program it an use that same action in other places in the app.
For example the native EditAction is a custom class than can be used in several places with the same functionality. The same can be done with an Action that has a modal.
okay, thanks!