Possible to combine JS loadedOnRequest with Alpine.data?

This gives undefined foo error - which's a function that's defined inside the foo.js file.

<div 
    x-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('foo'))]"
    x-data="foo()"
>


const foo = () => ({
    // ...
});
window.Alpine.data("foo", foo);
Was this page helpful?