Call Component function from Action button
is it possible to have an Action that when clicked calls a method on the component passing in the row's record (or just id of that row's record)? I cant find an example and currently when i click it reloads the whole page.
context...
I have a seperate audio-player component that I want to pass a new
src
route to based on the row record.
I have a working Table component to which i want to add an action that changes a public variable (on that tabel component) something like:
fyi: earlier in the code i define $parent
the issue i have is that clicking the play button triggers a reload of the page, so even though i set the public livewire component variable $src
it reloads and gets set back to '#' .
thanks.
Paul.6 Replies
Is this in the panel or livewire component?
custom livewire component. Not in the filament panel / admin system π
setSrc()
is found on the same component?yeah.. using the $parent = $this; and then calling $parent->setSrc() does now seem to be working, just feels very hacky - lol
i don't get it why are you assinging $this to $parent? just call
$this->setSrc()
There is a scope issue where you cant access $this from the anonymous function closure being passed into ->action(). Using arrow functions might work around that as it would normally allow access to parent variables but $this might be slightly different in this context (i havent tested it tbf let me have a quick go now)
hmm.. ok cool can confirm by using arrow functions
does work
previously i was doing more in that method so arrow function wasn't viable but have now simplified it so that does work π awesome.