Class 'w--current' not being added to class list

Hello,

The class w--current is not being added to the nav bar link to the current page in the specific scenario where I’ve used JavaScript to dynamically add parameters to the above link’s URL.

I’ve also tried giving the nav bar link its own ID and then adding the class to that ID (via Javascript), and while I generally can add classes, the specific class w--current cannot be added – it gets ignored.

I believe this is a bug because just because I’ve dynamically added parameters to the URL, that doesn’t mean the class w--current should be not added to the button.

please see this video to clarify the problem I’m describing:

You can view the two pages featured in the video here: working and not working.

Here is my site Read-Only: https://preview.webflow.com/preview/jfa1n9rinw36lptc?preview=bba858e775f2f61ee2e4340e52e65033

What are your thoughts? Is this a bug, or am I not doing something correctly?

Thanks,

Will

Hi @wzahra,

I don’t think it is a bug but it might be easier to understand what you have tried if we could see your custom code and also which page of your project we should look at.

Otherwise I think (not 100% sure) w-current is not really a class nor a state but more a conditional checking script (client or server side) of the url to apply different styles (a bit like combo classes)

Because Webflow handle CMS capabilities and therefore generates pages dynamically, I reckon it is not just about adding a class to the class list but adding css properties to the desired classes.

Again my knowledges are still limited and I might be totally wrong on what you meant :crazy_face:

I hope it can be a beginning of answer and I will be happy to help if you can provide more precise details of your setup.

Max

2 Likes

Hi @Maximosaurus,

Thanks for your reply; please see my updated original post for links to both the working and not working pages, plus a video.

Thanks.

Hi @wzahra,

Great question, and I’m here to help!

Yes, as the URL is changed (though it is just additional parameters) the w--current would not be available for that link.

A suggestion is to create a custom w-current class such as c-current-link and style this class to your liking.

Then, you can add the class name via Javascript.

2 Likes

Hi @mistercreate,

Thanks for your reply; I’ll try that.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.