'SB Admin is not expanding sidebar when has active child
I am creatind an admin panel for my website using SB Admin Pro. Normaly Sb Admin Pro as in https://themes.startbootstrap.com/sb-admin-pro/ the sidebar menu is expanded when any of it's child has "active" class i.e it's link matches window.location.
In my case the a.nav-link is having "active" class whenever it is active but it's parent collapse is not expanded on page load.
Did anybody faced this before, which action can cause this issue. Any comments?
Solution 1:[1]
you can replace script on script.js
with this
$(document).ready(function () {
let path = window.location.href.split('?')[0];
$("#layoutSidenav_nav .sb-sidenav a.nav-link").each(function () {
if (this.href === path) {
$(this).addClass("active");
var level = $(this).parent();
if (level.is('nav')) {
level.parent().addClass("show");
level.parent().prev().addClass("active");
}
}
});
});
hope this help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MILAN SAHANA |
