Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jaspercreel's avatar

Event listeners being removed after filtering

I have a class, ModelTable, that displays, you guessed it, a table of models. This is a livewire component. I have sub classes that extend this class for different kinds of models (e.g. customer).

Each row in the table has a delete button that can, you guessed it, delete the model. The button emits an event from the table component to open a modal, asking for confirmation to delete and passing it the id. The modal emits its own event confirming the deletion back to the table.

This works great, until I filter the models. The models live on a public property, and the filters build a query which replaces this property with the results of the query. As soon as I replace them, the delete buttons stop working. They don't fire any network requests, its like the click listener has been stripped away.

Anyone else run into this type of problem before? I have tried adding wire:key to the buttons, but that does not work. I have tried making the buttons their own livewire component, but that does not work either. Any help would be appreciated. Thanks!

0 likes
5 replies
jaspercreel's avatar

@click I tried adding it to each individual button, because I am rendering the table using css grid. No individual rows in the markup, I was just calling them rows semantically. Also no, no JS error

brandymedia's avatar

@jaspercreel hey there - was there ever any resolution to this?

I've been encountering the same thing. I have a dropdown button that uses event listeners which become broken after filtering the data.

Cheers

Please or to participate in this conversation.