F
Filament11mo ago
Prodex

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:
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?
Jump to solution
6 Replies
awcodes
awcodes11mo ago
You only need that in one place. It should be in your parent livewire component.
Prodex
ProdexOP11mo ago
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
awcodes
awcodes11mo ago
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?
Prodex
ProdexOP11mo ago
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.
awcodes
awcodes11mo ago
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.
Prodex
ProdexOP11mo ago
okay, thanks!
Want results from more Discord servers?
Add your server