Toasts now work with turbo

This commit is contained in:
Jan Böhmer 2022-07-24 14:20:20 +02:00
parent 3df6e18a83
commit 390deca544
6 changed files with 57 additions and 41 deletions

View file

@ -0,0 +1,17 @@
import { Controller } from '@hotwired/stimulus';
import { Toast } from 'bootstrap';
export default class extends Controller {
connect() {
//Move all toasts from the page into our toast container and show them
const toastContainer = document.getElementById('toast-container');
if (this.element.parentNode !== toastContainer) {
toastContainer.appendChild(this.element);
return;
}
const toast = new Toast(this.element);
toast.show();
}
}