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

brunobacha's avatar

Issue with Updating Table

When I delete a record from the first row of the table, the confirmation modal shows, and upon confirming the deletion, the record is successfully deleted, and the table is updated using Livewire. dispatch('refreshTable').

However, when I delete another record in the first row of the updated table (the correct data-url for the record is set), the actionUrl is incorrectly referencing the previously deleted record, triggering an error that the record has already been deleted (the ID of the first deleted record).

But when I try to delete a record in the second row of the table, the actionUrl is updated correctly, and the deletion is successful. The table is then updated again.

When I try to delete another record, either in the first or second row, the actionUrl is not updated correctly, meaning it’s still referencing the actionUrl from the previously deleted records (the first and second deleted records).

How can I resolve this?

Here’s the code:

And the code of link Delete:

<a class="dropdown-item text-danger action-confirm" href="#" data-url="http://app.test/admin/bid/boletim/81" data-method="DELETE" data-message="Tem certeza que deseja excluir o registro?"><!--[if BLOCK]><![endif]--><i class="fa-solid fa-trash-alt me-2"></i><!--[if ENDBLOCK]><![endif]-->Delete</a>

Open for other suggestions! Thanks!

0 likes
1 reply
jlrdw's avatar

Where are values coming from:

                    var actionUrl = $(this).data('url');
                    var actionMethod = $(this).data('method');
                    var confirmationMessage = $(this).data('message');

Are you refreshing the fields with ajax properly?

Otherwise if a field was 1, it will still be 1.

Show the form, or code of where you are getting your data.

A server fetched partial will refresh if using a table.

https://laracasts.com/series/javascript-techniques-for-server-side-developers/episodes/1

I use inside an object to maintain pagination and search functions.

Please or to participate in this conversation.