diff --git a/members/static/members/js/tab.js b/members/static/members/js/tab.js index 86e5b693..b337d04e 100644 --- a/members/static/members/js/tab.js +++ b/members/static/members/js/tab.js @@ -13,7 +13,8 @@ document.addEventListener("DOMContentLoaded", function(event) { const urlFragment = window.location.hash.substring(1); // Remove the '#' char // Default to the first list item as active if the ID is not provided or doesn't match any item - const activeIndex = tabButtons.findIndex(button => button.id === urlFragment); + // we use custom attribute data-navigation to set the "navigation url" for tab + const activeIndex = tabButtons.findIndex(button => button.dataset.navigation === urlFragment); const defaultIndex = activeIndex !== -1 ? activeIndex : 0; // Default to first as active @@ -38,6 +39,9 @@ function toggleActive(sections, buttons, activeIndex) { sections[activeIndex].hidden = false; // set url to include the tab identifier. we overwrite url, since tabs doesn't work otherwise - const newUrl = window.location.pathname + `#${buttons[activeIndex].id}`; - window.history.replaceState({}, "", newUrl); + // we use custom attribute data-navigation to set the url for tab + if (buttons[activeIndex].dataset.navigation) { + const newUrl = window.location.pathname + `#${buttons[activeIndex].dataset.navigation}`; + window.history.replaceState({}, "", newUrl); + } } diff --git a/members/templates/members/activities.html b/members/templates/members/activities.html index be347182..1735bbe2 100644 --- a/members/templates/members/activities.html +++ b/members/templates/members/activities.html @@ -15,11 +15,11 @@

Aktiviteter i Coding Pirates

diff --git a/members/views/ActivitySignup.py b/members/views/ActivitySignup.py index 8470a051..3cf63305 100644 --- a/members/views/ActivitySignup.py +++ b/members/views/ActivitySignup.py @@ -148,7 +148,7 @@ def ActivitySignup(request, activity_id, person_id=None): participant.save() # return user to list of activities where they are participating - return_link_url = f'{reverse("activities")}#tab-tilmeldte-aktiviteter' + return_link_url = f'{reverse("activities")}#tilmeldte-aktiviteter' # Make payment if activity costs if activity.price_in_dkk is not None and activity.price_in_dkk > 0: