Target specific table row from laravel event

I have a table where each row is a laravel component. In here I have a status field that will change elsewhere in the application. I have an event set up and a listener in the table row component. This all works fine and it picks up the change. The trouble is, it updates all rows.

I’m sending wire:key when each row is built which incidentally doesn’t look right in developer tools and I can also bring the correct key back in the listener, just not sure how to marry the 2 up.


I had another image but can only post one.


I think the most efficient way is to do it in a parent livewire component that loops out each table row component (if you don’t have it setup that way already, but I think you do). Then you could change the status before the table rows are looped out, and only one livewire request round trip.

A knee jerk way would be to listen to the changeStatus event on the table row component and check if ids match, but that would result in a round trip request for every table row that exists on the page.

I also think there would be a way to leverage the component id ($this->id) to dynamically generate and target the event listener to just the single table row it should, but

  1. I’m not 100% what that would look like.
  2. You could run into issues because the component id is generated every page load, and would be different if the user does any page changes or refresh.