masmerise / livewire-toaster

Beautiful toast notifications for Laravel / Livewire.
MIT License
342 stars 22 forks source link

Uncaught ReferenceError toasts & toasterhub #18

Closed Altffenser closed 10 months ago

Altffenser commented 10 months ago

I get this error. I read in another post that it was due to the inclusion of Alpine via CDN. My case is different because Alpine in my project is referenced through NPM. I have tried many things like changing the import order in the "app.js" file as well as in my layout and none of that works. What could be causing these errors?

Anyone who has had this happen and can help me a bit with this?

tSJecCF

y8w8iHw

Laravel version: 10.8 PHP version: 8.2 Livewire version 2.12.6 Toaster version: 1.3

mabdullahsari commented 10 months ago

You'll have to show how your app.js file is composed.

Altffenser commented 10 months ago

You'll have to show how your app.js file is composed.

An apology, I have managed to solve it and is that at the time of importing the module in the "app.js" file must be referenced with a name.

import Toaster from '../../vendor/masmerise/livewire-toaster/resources/js';

Then Alpine.plugin(Toaster);

thanks to @dev

mabdullahsari commented 10 months ago

You'll have to show how your app.js file is composed.

An apology, I have managed to solve it and is that at the time of importing the module in the "app.js" file must be referenced with a name.

import Toaster from '../../vendor/masmerise/livewire-toaster/resources/js';

Then Alpine.plugin(Toaster);

thanks to @dev

The current README docs is for v2 which doesn't require that. 😉 Glad you got it sorted out!