mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2026-02-04 10:35:30 +00:00
FIX: back-links in bearbeiten-Formularen
This commit is contained in:
@@ -179,6 +179,31 @@ function ShowBoostedErrors() {
|
||||
});
|
||||
}
|
||||
|
||||
function setupCancelLinks(root = document) {
|
||||
const links = root.querySelectorAll("[data-role='cancel-link']");
|
||||
links.forEach((link) => {
|
||||
if (link.dataset.cancelBound === "true") {
|
||||
return;
|
||||
}
|
||||
link.dataset.cancelBound = "true";
|
||||
const cancelUrl = (link.getAttribute("data-cancel-url") || "").trim();
|
||||
if (cancelUrl) {
|
||||
link.setAttribute("href", cancelUrl);
|
||||
return;
|
||||
}
|
||||
link.addEventListener("click", (event) => {
|
||||
const resolved = (link.getAttribute("data-cancel-url") || "").trim();
|
||||
if (resolved) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
if (window.history.length > 1) {
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// INFO: Hooks up to all the reset button children of the target element.
|
||||
// If an element has a changed state, it will trigger the action with `true`.
|
||||
// If no elements are changed, it will trigger the action with `false`.
|
||||
@@ -224,6 +249,15 @@ function supportsFieldSizing() {
|
||||
return browserSupportsFieldSizing;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
setupCancelLinks(document);
|
||||
});
|
||||
|
||||
document.addEventListener("htmx:afterSwap", (event) => {
|
||||
const root = event.detail?.target || document;
|
||||
setupCancelLinks(root);
|
||||
});
|
||||
|
||||
// Simple textarea auto-resize function
|
||||
function TextareaAutoResize(textarea) {
|
||||
console.log("TextareaAutoResize called for:", textarea.name || textarea.id);
|
||||
|
||||
Reference in New Issue
Block a user