mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-27 05:19:31 +00:00
Toasts now work with turbo
This commit is contained in:
parent
3df6e18a83
commit
390deca544
6 changed files with 57 additions and 41 deletions
17
assets/controllers/common/toast_controller.js
Normal file
17
assets/controllers/common/toast_controller.js
Normal 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import "bootstrap-fileinput";
|
|||
|
||||
const RegisterEventHelper = class {
|
||||
constructor() {
|
||||
this.registerToasts();
|
||||
this.registerTooltips();
|
||||
this.registerJumpToTopBtn();
|
||||
|
||||
|
|
@ -28,10 +27,6 @@ const RegisterEventHelper = class {
|
|||
document.addEventListener('turbo:load', fn);
|
||||
}
|
||||
|
||||
registerToasts() {
|
||||
this.registerLoadHandler(() => $(".toast").toast('show'));
|
||||
}
|
||||
|
||||
registerTooltips() {
|
||||
this.registerLoadHandler(() => {
|
||||
$(".tooltip").remove();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue