Alpine Expression Error: fileUploadFormComponent when loading page first time
What I am trying to do:
Load a form with FileUpload field in an existing Laravel app (using only forms/tables, not the full panel)
Using Filament v3 due to conflicting dependencies with other plugins.
My issue / error:
On first page load, a default HTML upload button appears. Selecting a file shows an error on submit: nothing selected.
Console: Alpine Expression Error: fileUploadFormComponent is not defined
Refreshing the page enables drag-and-drop and the form works. But next login requires refresh again.
What I did:
Installed Filament Forms v3
Updated files per docs
Separated loading Filament and Datatables to avoid Alpine double-init
Tried moving app.js before/after @filamentScripts
Code:
importing filamentScripts in app.blade before closing body tag with:
@filamentScripts
@vite('resources/js/app.js')
Component code:
Blade:
13 Replies
Are there any errors in DevTools Console or Network tab? Sounds like the file is not loaded the first time.
Yes the errors in DevTools Console are:
Alpine Expression Error: fileUploadFormComponent is not defined
Expression: "fileUploadFormComponent({
...}
Alpine Expression Error: error is not defined
Uncaught ReferenceError: error is not defined
at [Alpine] error (eval at safeAsyncFunction),
at livewire.js
at tryCatch
at livewire.js
at reactiveEffect
at Object.effect2
at effect
at wrappedEffect
at Function
at flushHandlers
Sorry, you already said, there's an console error. 🙈 Is there an error in network tab? Sounds like the JS is not loaded.
No problem, now I could post the entire errors haha.
The network tab only loads two files to start with:
notifications.js
support.js
After refresh the other files get added:
app.js / livewire.js / file-upload.js
Okay, it's weird that those files are missing.
How do you load them in your layout?
It's super-weird because even your
app.js is not loaded on first request.
When you load the page, is that file in the HTML?They are in the HTML, that makes it even more weird.
Even in the x-load-src the file-upload.js is mentioned, and the app.js (with the same suffix as in the assets folder) is in the HTML too. When I compare the rendered HTML before refresh and after refresh only the wire:id/snapshots differ, everything else stays the same.
could you share the
app.js?Are you using spa mode?
This is in the app.js:
import './bootstrap';
import '../../vendor/rappasoft/laravel-livewire-tables/resources/imports/laravel-livewire-tables-all.js';
And yes, we use spa mode. Tried to remove the wire:navigate. Then the page is a 'fresh' load when you open it, so that works. Would it be best to remove the wire:navigate or is there another option to load the right files?
And yes, we use spa mode. Tried to remove the wire:navigate. Then the page is a 'fresh' load when you open it, so that works. Would it be best to remove the wire:navigate or is there another option to load the right files?
did you try it without
rappasoft/laravel-livewire-tables?Yes, my first idea was that it would load Alpine twice, but removing it has no effect