• Hello,

    I am trying to implement the feature that the design of “qem-category” is changed when the user is already on the specific category URL the button links to.

    This script is working fine:

    <script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function() {
    const currentUrl = window.location.href;
    document.querySelectorAll(".qem-category a").forEach(function(link) {
    if (currentUrl.includes(link.href)) {
    link.parentElement.classList.add("active");
    }
    });
    });
    </script>

    However the category buttons are only changing design (via CSS) after the second click. I see that the URLs, which are generated after the click, are wrong.

    So I have two categorys: Cat1 and Cat2. When I click on Cat1 the URL is:

    https://address.tld/events/?category=cat1

    After clicking on the Cat2 button:

    https://address.tld/events/?category=cat1&category=cat2

    Something is wrong there and I think that’s why my script only works after the second click. Can you please assist me with that issue?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Sounds like it is appending the category rather than replacing the category.

    You can investigate via the source code here https://github.com/alanef/quick-event-manager and if you identfify the issue I will consider a pull request.

    Also, it would probably be better to add a css selector to the active button via the code rather than javascript and I would happily incorporate that if you create a pull request that does so.

    Thread Starter genauder

    (@genauder)

    I would love to use CSS only but I cannot make it work since it’s not really an active button / the class does not change after the category button is clicked. Or I am doing something wrong fundamentally. Can you please tell me how to do this via CSS only?

    • This reply was modified 1 year, 2 months ago by genauder.

    it would take coding change to the core plugin to add an active class, if you have time and skill to investigate the core code then that would be fantastic, otherwise I’ll take a look when I have a spare moment.

    Thread Starter genauder

    (@genauder)

    I am not skilled enough so your help would be highly appreciated. Thank you!

    I have released 9.14 with those minor changes

    Fixes that issue with extra categories – but more usefully adds the class qem-active-category

    which I set to have a little ‘feel’ with this css ( which of course you can override )

    .qem-active-category {
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.8);
    }

    Thread Starter genauder

    (@genauder)

    Great stuff, thank you very much!

    Thread Starter genauder

    (@genauder)

    Maybe if possible you can also add an addtional class for the “all” categories tab when activated? It’s grey with white font color, it doesn’t look very nice and it also seems to miss an extra class so I can’t really change.

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘URL when clicking on category keys’ is closed to new replies.