themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.89k stars 742 forks source link

Cannot Close Modal With Laravel Livewire Event #961

Open dbarou55e opened 1 month ago

dbarou55e commented 1 month ago

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();