I have a loop of a livewire component in php:
@foreach
{{-- my livewire component --}}
@endforeach
Inside my Livewire component I have a function called “addComment”, this is also in the listeners.
From inside the loop I have JS function that has to fire “addComment” only for that component:
window.livewire.emit('addComment', e.currentTarget.value, postId);
But because the component is rendered 15 times (loop) and “addComment” is on listening 15 times. For many reason I have to fire the event from JS and not from php wire:click.
I thought “emitSelft” sounded delicious, but I tried doing this in JS:
window.livewire.emitSelf('addComment', e.currentTarget.value, postId);
But it says emitSelf does not exist