Trigger Action automatically when page loads

Hi, I want to trigger an action upon a page loads, but I can't find a method that triggers a button click, is there any way?
4 Replies
awcodes
awcodes15mo ago
You'd have to do that with some custom javascript.
Javier Mercedes
Javier MercedesOP15mo ago
Thanks, is there any example that I can follow?
awcodes
awcodes15mo ago
no that i know of. but you could use a renderhook to inline it or load a .js file with the code too.
waleedGRT
waleedGRT12mo ago
Perhaps this code could be helpful for someone.
->extraAttributes(function () {
$config += [
'wire:init' => new HtmlString('mountAction(\'modelname\')'),
]
return $config;
})
->extraAttributes(function () {
$config += [
'wire:init' => new HtmlString('mountAction(\'modelname\')'),
]
return $config;
})

Did you find this page helpful?