© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
7 replies
ChrisR

How to execute javascript within a modal

I have a modal that is initated with an action:

TextColumn::make('order_id')
  ->action(
    Action::make('scan-item')
      ->label('Scan Items')
      ->modalContent(view('prototypes.scanner'))
      ->action(function (Order $record): void {

      })
      ->modalWidth('Screen')
      ->slideOver()
    ),
TextColumn::make('order_id')
  ->action(
    Action::make('scan-item')
      ->label('Scan Items')
      ->modalContent(view('prototypes.scanner'))
      ->action(function (Order $record): void {

      })
      ->modalWidth('Screen')
      ->slideOver()
    ),

This opens the modal slideover correctly, and I see the correct content. However, I need to execute some javascript after the modal loads. I've tried updating my blade to do this:

<x-app-layout>
    foo bar
    @push('modals')
        <script>
            console.log('Script is running');
        </script>
    @endpush
</x-app-layout>
<x-app-layout>
    foo bar
    @push('modals')
        <script>
            console.log('Script is running');
        </script>
    @endpush
</x-app-layout>


I do have the
@stack
@stack
in my app.blade.php file:

@livewireScripts        @vite('resources/js/app.js')
@stack('modals')
@livewireScripts        @vite('resources/js/app.js')
@stack('modals')


But that
console.log
console.log
doesn't execute. So, I have two questions:

1. How do I execute JS in a modal
2. There will be several table rows with the same action, that execute the same JS - is there a better way to do this?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to Control Filament Modal with JavaScript and Execute Custom Logic?
FilamentFFilament / ❓┊help
13mo ago
How to Control Filament Modal with JavaScript and Execute Custom Logic?
FilamentFFilament / ❓┊help
13mo ago
Open modals, within a Modal with a infolist?
FilamentFFilament / ❓┊help
2y ago
edit/delete modal from within relationship modal
FilamentFFilament / ❓┊help
11mo ago