Close action modal with event

I have a table action which open a livewire component, I that livewire there is one more table action which open a modal(blade file) I want to close the livewire component when blade modal is open or close both blade modal and livewire component when blade modal is close
Action::make('link payment')
->disabled(fn ()=>$this->policies())
->label('Link Payment')
->extraModalWindowAttributes(['id' => 'orphan-payment-modal'])
->form([
Grid::make(6)
->schema([
])
->extraAttributes(['class' => 'orphan-payment-details']),
View::make("livewire.payment-search-render-helper")
->extraAttributes(['class' => 'contact-search-table'])
])
Action::make('link payment')
->disabled(fn ()=>$this->policies())
->label('Link Payment')
->extraModalWindowAttributes(['id' => 'orphan-payment-modal'])
->form([
Grid::make(6)
->schema([
])
->extraAttributes(['class' => 'orphan-payment-details']),
View::make("livewire.payment-search-render-helper")
->extraAttributes(['class' => 'contact-search-table'])
])
I tried giving id to livewire modal and dispatch close-modal event from second table action but it didn't worked
Action::make("Link Payment")
->label('')
->form(
function ($record) {
$this->contact = $record;
$this->invoiceGeneration();
$this->dispatchFormEvent('close-modal', ['id' => 'orphan-payment-modal']);
$this->dispatch('link-payment');
info('dispatch');
return [
$this->orphanPaymentDetails(),
$this->status ? View::make('filament.pages.payment-link-success-modal') : View::make('filament.pages.payment-link-failed-modal')
];
}
)
Action::make("Link Payment")
->label('')
->form(
function ($record) {
$this->contact = $record;
$this->invoiceGeneration();
$this->dispatchFormEvent('close-modal', ['id' => 'orphan-payment-modal']);
$this->dispatch('link-payment');
info('dispatch');
return [
$this->orphanPaymentDetails(),
$this->status ? View::make('filament.pages.payment-link-success-modal') : View::make('filament.pages.payment-link-failed-modal')
];
}
)
14 Replies
Arghyaashu
ArghyaashuOP3mo ago
Just to keep it on ..
Arghyaashu
ArghyaashuOP3mo ago
It worked Perfectly but when event dispatched from second action's form it closes both modals Is there any way to dispatch the even from 'X' button of modal
LeandroFerreira
LeandroFerreira3mo ago
You’ll need to inspect the code to understand what the ‘x’ does and then try to trigger the same action
Arghyaashu
ArghyaashuOP3mo ago
on click it closes the second modal I didn't get which action should I try
No description
LeandroFerreira
LeandroFerreira3mo ago
Shouldn't it be x-on:click in the button?
Arghyaashu
ArghyaashuOP3mo ago
yes, but in blade file there is no button. How can I use x-on:click?
No description
Arghyaashu
ArghyaashuOP3mo ago
..
LeandroFerreira
LeandroFerreira3mo ago
I didn't understand your question..
Arghyaashu
ArghyaashuOP3mo ago
like in inspect it dispatch from x-on:click but in my blade file I didn't mentioned any button. so, How can I use x-on:click? to dispatch the event
LeandroFerreira
LeandroFerreira3mo ago
when would you like to dispatch the event?
Arghyaashu
ArghyaashuOP3mo ago
when user click on 'x' button
LeandroFerreira
LeandroFerreira3mo ago
I don't know.. maybe you can disable the x button in the modal and create a custom button to dispatch it
Arghyaashu
ArghyaashuOP3mo ago
OK, thanks for helping me out
Want results from more Discord servers?
Add your server