I’m having a hard time getting the “active” class to stay across different pages. I have the navbar loading on each page via a layout, could this be the issue?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, that is the issue.
Whenever you reload the page, whatever
<li>element hasclass=activewill be set to active again.If you have
/grails-app/views/layouts/main.gspwith the following:And your GSPs for Fred and Barney use the main.gsp layout, when you click on them, you will load the code above and the link for “Home” will still be active.
Solutions are to write a Taglib for the Navbar control, or create separate layout pages.