Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/arifurdev/toastr-integration-livewire
- Owner: ArifurDev
- Created: 2024-05-20T20:37:46.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-20T20:53:24.000Z (7 months ago)
- Last Synced: 2024-10-31T05:05:06.916Z (about 2 months ago)
- Topics: events, livewire, livewire-laravel, livewire3, toast-notifications, toastr, toastr-integration-livewire, toastr-notifications, tostar
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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' );
```