Make table update when variable changes
Custom page with a livewire component that has a table needs to update the table when a variable changes.
There are more parts to the issue, but it boils down to the code below, when changeVar is called from livewire component the var changes (can be seen on the page), but the table header does not.
If I click the button once more, the table updates - so the table is always lagging 1 event.
`
Solution:Jump to solution
So seems emit was renamed to dispatch in v3, I got the refresh working with the below code, thanks for the help.
```
class TableTest extends Component implements HasForms, HasTable...
10 Replies
Can you share your
livewire.table-test
view?
And the TableTest component
But I am thinking maybe I need to use filament actions instead of trying to use livewire click directly?
I'm not sure an action will change anything but you could try, not a bad idea
So if I understand correctly, you click the button once, then you see the updated
{{ $this->var }}
in the page? But your table header also reads the same variable and it's not updated. But if you click the button a second time, the table header is updated. Right?correct
I think you can force a refresh on the table... 1 sec I'll look in some code I have here
My problem is a bit different from yours but here's an idea you can try:
I changed it to a filament action, just to try it out and it gives the same issue - I guess the reason is that the var is not directly a part of the table component, not that that explains why it updates if its just done 2 times though
Solution
So seems emit was renamed to dispatch in v3, I got the refresh working with the below code, thanks for the help.
Ah yes, my bad! I lost track of the
v3
tag you added.
Glad you were able to solve it 😄