jquery not working with laravel orchid button

202 Views Asked by At
 public function commandBar(): array
    {
        
         $buttons[] = Button::make('Preview')->id('ddd')
                   ->icon('check')
                   ->method('preview');
                   
        return $buttons;
    }

I m new in Laravel Orchid.I wanted to target the preview button by id and perform some javascript action.

Please let me know in which file should i write javascript?

1

There are 1 best solutions below

0
On

The most common answer is in Orchid documentation:

Orchid’s seamless administrative panel experience is powered by Turbo.

document.addEventListener("turbo:load", () => {
    console.log('Page loaded');
})

Since all resources will be loaded on the first call, classic calls will not work. Make sure that your script not waiting for document load and so on.