Skip to content

How to utilise emitUp type behaviour from a modal? #208

Answered by mlewist
mlewist asked this question in Q&A
Discussion options

You must be logged in to vote

Okay I just needed to dig a little further - this had come up in discussion on the Livewire repo before and Caleb had suggested a solution of dynamic listener names

livewire/livewire#845 (comment)

Then someone elaborated on this in a blog post: https://www.matthewerwin.co.uk/blog/single-component-events-in-laravel-livewire/?utm_source=github&utm_campaign=livewire/livewire/issues/845

So for me, in my various modals:

$this->closeModalWithEvents([
  InvoiceItem::getName() => 'invoicePaid:' . $this->invoice->id,
]);

And in the InvoiceItem component, instead of declaring protected $listeners = [], you do

protected function getListeners()
{
    return [
      'invoicePaid:' . $this->invoice->i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mlewist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant