Popup immer mit dem ersten Tab öffnen

This commit is contained in:
Cay 2026-03-13 08:18:16 +00:00
parent 339e9f8b41
commit abe9fda293

View File

@ -1,6 +1,22 @@
const popup = document.getElementById("building-popup");
const title = document.getElementById("popup-title");
function resetTabs() {
document
.querySelectorAll(".tab")
.forEach((t) => t.classList.remove("active"));
document
.querySelectorAll(".tab-content")
.forEach((c) => c.classList.remove("active"));
// erster Tab aktiv
const firstTab = document.querySelector(".tab");
const firstContent = document.querySelector(".tab-content");
if (firstTab) firstTab.classList.add("active");
if (firstContent) firstContent.classList.add("active");
}
document.querySelectorAll(".building").forEach((b) => {
b.addEventListener("click", async (e) => {
e.preventDefault();
@ -17,6 +33,7 @@ document.querySelectorAll(".building").forEach((b) => {
popup.style.top = "50%";
popup.style.display = "block";
resetTabs();
// AJAX Gebäudedaten laden
const res = await fetch("/api" + url);