wireui: Alpine Expression Error: wireui_notifications is not defined
Describe the bug I am trying to implement notification on a new project (with filamentadmin), but I can’t get it working. I always get
module.esm.js:416 Alpine Expression Error:
Alpine Expression Error: wireui_notifications is not defined
and
module.esm.js:420 Uncaught ReferenceError: wireui_notifications is not defined
And this even before calling $this->notification() or window.$wireui.notify({..., just directly on page load.
I have added <wireui:scripts /> next the the <head> tag, resulting in:
<head>
<script>window.Wireui = {hook(hook, callback) {window.addEventListener(`wireui:${hook}`, () => callback())},dispatchHook(hook) {window.dispatchEvent(new Event(`wireui:${hook}`))}}</script><script src="http://127.0.0.1:8001/wireui/assets/scripts" defer></script>
and right after the <body> tag I have added <x-notifications /> resulting in
<body class="bg-gray-100 text-gray-900 filament-body">
<div class="fixed z-50 inset-0 flex items-end justify-center px-4 py-6
pointer-events-none sm:p-5 sm:pt-4 sm:items-start sm:justify-end"
x-data="wireui_notifications"
x-on:wireui:notification.window="addNotification($event.detail)"
x-on:wireui:confirm-notification.window="addConfirmNotification($event.detail)"
wire:ignore>
.....
AlpineJS ist included at the end of the </body>.
WireUi Elements like Buttons are working.
Desktop (please complete the following information):
- OS: Ubuntu 20.04
- Browser Chrome
- Version 102
Additional context
$composer show | grep wireui
wireui/wireui v1.6.0 TallStack components
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (1 by maintainers)
Adding this for my future self and anyone else who wants to save 3 hours:
Had the same error after updating to Livewire 3. Solution was to remove loading of Alpine from app.js, because it is actually bundled with Livewire 3 already.
Thanks @rowino for pointing it out 😉
I had a similar issue. I think the problem was duplicated Alpine.js, since Laravel Breeze already includes it. Here is the
app.js:So all I did was change the
app.blade.php:Now everything works perfectly, no warnings or errors.
I have a same problem, then I put alpinejs in another js like alpinejs.js and add in the vite.config. I put @vite([‘resources/js/alpine.js’]) below {!! WireUi::directives()->scripts() !!} or @wireUiScripts, but im using {!! WireUi::directives()->scripts() !!}. It works for me before im searching about defer setting in vite, so i dont need setting defer in my vite