Hello,
i have very simple livewire component where i have foreach loop and inside i have also <button wire:clic.stop="showModal">Modal</button>
To show modal i using sweeAlert2, everyting working nice, after click button i have modal but i noticed that entire component with foreach loop is refreshed each time when i click this button, i looked everywhere in internet and i can't find solution for my problem :/
**ListItems.php: **
...
public function showModal() {
$this->dispatchBrowserEvent('sweet:modal');
}
list-items.blade.php
<div wire:loading.flex class="flex justify-center">
Loading icon...
</div>
<div wire:loading.remove class="space-y-4">
@foreach ($items as $item)
<div>
Some HTML code...
<button type="button" wire:click.prevent="showModal">
Show Modal
</button>
</div>
@endforeach
</div>
master.blade.php
<script>
addEventListener('sweet:modal', event => {
Swal.fire({
title: 'Hello',
text: 'Do you want to continue',
icon: 'error',
confirmButtonText: 'Cool'
});
})
</script>
I tried with listeners and emit and still no luck... What i missing here?