Fix several issues around browser back navigation (#825)

This commit is contained in:
Sascha Ißbrücker
2024-09-15 08:28:49 +02:00
committed by GitHub
parent 74e65bc366
commit db225d5267
10 changed files with 64 additions and 23 deletions

View File

@@ -16,7 +16,7 @@ const mutationObserver = new MutationObserver((mutations) => {
});
});
window.addEventListener("turbo:load", () => {
document.addEventListener("turbo:load", () => {
mutationObserver.observe(document.body, {
childList: true,
subtree: true,
@@ -25,6 +25,10 @@ window.addEventListener("turbo:load", () => {
applyBehaviors(document.body);
});
document.addEventListener("turbo:before-cache", () => {
destroyBehaviors(document.body);
});
export class Behavior {
constructor(element) {
this.element = element;