Custom Action within TablesRenderHook::TOOLBAR_SEARCH_BEFORE

Hello, I created custom render hook
->renderHook(
TablesRenderHook::TOOLBAR_SEARCH_BEFORE,
fn (): string => Livewire::mount('table-toolbar-items'),
)
->renderHook(
TablesRenderHook::TOOLBAR_SEARCH_BEFORE,
fn (): string => Livewire::mount('table-toolbar-items'),
)
Within component i created Action from "Filament\Actions\Action", it get's rendered but it wont have any effect when clicked any idea why?
4 Replies
awcodes
awcodes2d ago
What is the code of your livewire component? My guess is that you haven’t name the method correctly for it to get auto registered as an action.
Señor Nikola
Señor NikolaOP2d ago
public function generatePdfAction (): Action
{
return Action::make('generatePdfAction')
->label('Export to PDF')
->extraAttributes(['data-generate-pdf' => true])
.....
public function generatePdfAction (): Action
{
return Action::make('generatePdfAction')
->label('Export to PDF')
->extraAttributes(['data-generate-pdf' => true])
.....
Action is working now naming issue as you said, but when i try to access via JS that data-generate-pdf via click listner it does not have any effect...
document.addEventListener('livewire:init', function () {
document.querySelector('[data-generate-pdf]').addEventListener('click', function (e) {
document.addEventListener('livewire:init', function () {
document.querySelector('[data-generate-pdf]').addEventListener('click', function (e) {
awcodes
awcodes2d ago
Check the code in dev tools, it might have livewire click handler on it which could be conflicting with the js. I don’t think it’s documented but actions also support ->alpineClickHandler() that you can use instead.
Señor Nikola
Señor NikolaOP4h ago
Yeah, that worked! Thanks

Did you find this page helpful?