Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arifurdev/toastr-integration-livewire


https://github.com/arifurdev/toastr-integration-livewire

events livewire livewire-laravel livewire3 toast-notifications toastr toastr-integration-livewire toastr-notifications tostar

Last synced: 4 days ago
JSON representation

Awesome Lists containing this project

README

        

# Tostar

This setup ensures that your Laravel application can easily trigger Toastr notifications through Livewire events. Whether using Livewire v2 or v3, this guide covers the necessary steps to get Toastr notifications up and running in no time.

## Setup

1. **Include Toastr in your main layout:**

```html




```

2. **Configure Toastr options:**

```html

$(document).ready(function(){
toastr.options = {
"progressBar": true,
"positionClass": "toast-top-right",

// "closeButton": false,
// "debug": false,
// "newestOnTop": false,
// "preventDuplicates": false,
// "onclick": null,
// "showDuration": "300",
// "hideDuration": "1000",
// "timeOut": "5000",
// "extendedTimeOut": "1000",
// "showEasing": "swing",
// "hideEasing": "linear",
// "showMethod": "fadeIn",
// "hideMethod": "fadeOut"
}
});

document.addEventListener("livewire:init", () => {
Livewire.on("toast", (event) => {
toastr[event.notify](event.message);
});
});

```

3. **configure the Livewire component:**

```php
//you can use livewire v2
return $this->dispatchBrowserEvent('toast', message: 'Please try again!', notify:'error' );

//you can use livewire v3
return $this->dispatch('toast', message: 'Please try again!', notify:'error' );

```