Stefan Petrea
Stefan Petrea
FFilament
Created by Stefan Petrea on 7/10/2024 in #❓┊help
Cannot load <script type="module"> inside a custom form field
What I am trying to do: Load a <script> with type="module" inside a custom form field blade file. What I did: I tried many approaches, including:
<div x-data="{}" ax-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('agent_config'))]">
</div>
<div x-data="{}" ax-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('agent_config'))]">
</div>
FilamentAsset::register([
Js::make('agent_config', __DIR__ . '/../../resources/js/flowise.js')
->module()
->loadedOnRequest()
]);
FilamentAsset::register([
Js::make('agent_config', __DIR__ . '/../../resources/js/flowise.js')
->module()
->loadedOnRequest()
]);
@script
<script type="module">
import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
Chatbot.initFull();
</script>
@endscript
@script
<script type="module">
import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
Chatbot.initFull();
</script>
@endscript
My issue/the error:
livewire.js?id=c4fc8c5d:1125 Alpine Expression Error: Cannot use import statement outside a module

Expression: "import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
livewire.js?id=c4fc8c5d:1125 Alpine Expression Error: Cannot use import statement outside a module

Expression: "import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
1 replies