Skip to content
Snippets Groups Projects
Commit e1d816be authored by Marina Mădăraş's avatar Marina Mădăraş
Browse files

Change initialization order of script

parent e218326c
No related branches found
No related tags found
2 merge requests!229Version 2.2.1,!218Fix dropdown
......@@ -96,7 +96,6 @@
</div>
</th:block>
<script>
window.onload = function () {
function fetchGroup(group) {
const toReplace =
group.nextElementSibling.querySelector("[data-fetch]");
......@@ -113,9 +112,10 @@
})
.catch(error => {
console.error("Fetch error:", error);
toReplace.parentElement.innerHTML = `An error occurred when fetching the data`;
});
}
document.addEventListener("DOMContentLoaded", function () {
const groups = document.getElementById("groups");
groups.querySelectorAll(".accordion__header").forEach(g =>
g.addEventListener("click", function (event) {
......@@ -129,7 +129,7 @@
fetchGroup(g);
})
);
};
});
</script>
</div>
</th:block>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment