flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

Cannot Close Modal With Laravel Livewire Event

Open dbarou55e opened this issue 1 year ago • 0 comments

Inside of a Laravel Livewire component, I dispatch an event to a listener containing some Javacript that calls the .hide() method on the modal. Unfortunately, the modal does not close.

JS code:

document.addEventListener('livewire:load', () => { Livewire.on('closeModal', () => { const myModal = new Modal(document.getElementById('createCustomerModal')); myModal.hide(); }); });

Livewire Componant:

if ($userOrganization) { // Establish the parent-child relationship $userOrganization->children()->attach($organization->id, ['name' => 'some_relation_name']); }

$this->dispatch('closeModal'); $this->reset();

dbarou55e avatar Sep 13 '24 17:09 dbarou55e