addAction function called on page load

When I have a repeater with an addAction function. When I load the page with the repeater on it the addAction code is executed. I would expect this to be called only when pressing the action button.
->addAction(function ($livewire, $component) { dump('test');})
->addAction(function ($livewire, $component) { dump('test');})
Any suggestions? Thanks.
3 Replies
awcodes
awcodes3mo ago
It’s because you are calling dump. It will just execute. Typically to override the action itself you would use injection to get the $action that is registered on the field and override it in the callback. Like $action->action() etc.
JJSanders
JJSandersOP3mo ago
Hey @awcodes tnx voor your reply. The way I understand it is that I don't call dump. What I intend to do with this code is that when I press the add button, only then the dump should be executed. So I don't understand why the addAction is called when I don't press the add button. ohhhh is this what I am supposed to do?
->addAction(function ($livewire, $component, $action) {
$action->action(function(){
dump('test');
});
})
->addAction(function ($livewire, $component, $action) {
$action->action(function(){
dump('test');
});
})
Probably
Want results from more Discord servers?
Add your server