Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit a8a3fb1

Browse files
committed
feat(app): De-/Initialize tooltips for page navigation
1 parent c7d9fc2 commit a8a3fb1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

assets/app/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
import "bootstrap";
1+
import * as bootstrap from "bootstrap";
22
import "./bootstrap.ts";
3+
4+
/**
5+
* Initialize tooltips of Bootstrap
6+
*/
7+
document.addEventListener("turbo:load", () => {
8+
const tooltipTriggerList = document.querySelectorAll("[data-bs-toggle=\"tooltip\"]");
9+
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
10+
11+
// Destroy tooltips on navigating to a new page
12+
document.addEventListener("turbo:before-visit", () => {
13+
for (const tooltip of tooltipList) {
14+
tooltip.dispose();
15+
}
16+
}, {
17+
once: true,
18+
});
19+
});

0 commit comments

Comments
 (0)