I am using Play Framework 2 for Java and Bootstrap Helper in my project and I want to apply active
class on sidebar link click. I am using side nav bar for navi
Finally I got solution for my problem, I am sharing my solution for others too. Firstly I created a method inside my html scala template file.
@activeLink(currentPath:String) = @{
if(request.path.equals(currentPath)) "active"
}
Now need to call the above method inside class
attribute of anchor
tag.
<ul class="nav nav-list">
<li class="@activeLink("/menu1")"><a href="/menu1">Menu1</a></li>
<li class="@activeLink("/menu2")"><a href="/menu2">Menu2</a></li>
<li class="@activeLink("/menu3")"><a href="/menu3">Menu3</a></li>
</ul>
Here is my final solution, If some one has another solution or approaching different way for the same so please share those also.