Topic: changing nav-item active in mvc java app
I'm using navbar in my java mvc app. I put navbar in my own tags library under WEB-INF/tags so that I don't have to replicate code in each jsp view. However, I can't determine how I change the corresponding navbar tab to make use of
<lib class="nav-item" active>
As a result, the Navbar never changes scope using that visual indicator. I'm assuming that this is what puts the faded box behind the tab name to show that it is the current tab in use. Is there something that I can add to my Get/Post sections of my controller, or to the corresponding jsp page that will make this change to the correct <li>
item?
I added an 'id' attribute to each <li>
element and inserted this piece of javascript into one of the pages but it didn't have any effect.
<script>
var x = document.getElementById("li2");
if (x.className === "") {
x.element.className = "active";
}
</script>
gjfrick answered 6 years ago
Thanks for the response. I just mentioned Java MVC to add some context, but I didn't think that whatever the solution, it wouldn't have any constraints based upon that. In general how is the nav button selection changed to reflect "nav-item active". Is that something that MDB handles automatically and something that I'm doing is getting in the way? For me this just looks like a typical HTLM page with some JSP scripts involved.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: desktop
- Browser: Firefox
- OS: Windows
- Provided sample code: No
- Provided link: No
Sebastian Kaczmarek staff pro premium commented 6 years ago
I don't like to say that, but we do not provide the out-of-the-box support for Java MVC apps with MDB. I cannot provide you with anything more than just a suggestion to try some workarounds. Also, if that's not a problem, please share your solution here once you find one.