You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any efficient way to remove the sidebar from a specific page? For example, for my charts.html file, I want to only display the top header but remove the sidebar completely. Is there any elegant solution to this?
@aryehbeitz Nice solution, but now everytimes that you switch to another page, the sidebar collapses even if it was opened in the previos page. Any way to keep the state of the sidebar between views?
@garciaba
Ok, I found a solution using the localStorage.
In the sb-admin-2.js file, first remove the code above from inside the $(function() {. Then, add the following to the bottom of the file, outside any function:
function hideNavbar() {
$("#page-wrapper").css({"margin": "0"});
$('div.navbar-collapse').addClass('collapse');
$('#side-menu').hide();
}
function unhideNavbar() {
$("#page-wrapper").css({"margin": "0 0 0 250px"});
$('div.navbar-collapse').removeClass('collapse');
$('#side-menu').show();
}
function toggleNavbar() {
if (localStorage.showNavbar == 1) { //showing and want to hide
hideNavbar();
}
else {
unhideNavbar();
}
localStorage.showNavbar = (localStorage.showNavbar == 0)?1:0;
}
Now in the file sidebar.js, add to the body of the controller:
if (localStorage.showNavbar === undefined) {
localStorage.showNavbar = 1;
}
if (localStorage.showNavbar == 1) {
unhideNavbar();
} else {
hideNavbar();
}
Leave the line in the header.html as: <a class="navbar-brand" onclick="window.toggleNavbar()" style="cursor: pointer;">SB Admin 2</a>
Activity
aryehbeitz commentedon Dec 16, 2015
I found a way:
on header.html i change to
<a class="navbar-brand" onclick="window.toggleNavbar()" style="cursor: pointer;">SB Admin 2</a>on sb-admin-2.js i add inside
$(function() {`
Then when clicking on the title, it toggles the side bar
Enjoy :)
garciaba commentedon Feb 29, 2016
@aryehbeitz Nice solution, but now everytimes that you switch to another page, the sidebar collapses even if it was opened in the previos page. Any way to keep the state of the sidebar between views?
aryehbeitz commentedon Mar 20, 2016
@garciaba
Ok, I found a solution using the
localStorage.In the sb-admin-2.js file, first remove the code above from inside the
$(function() {.Then, add the following to the bottom of the file, outside any function:
Now in the file sidebar.js, add to the body of the controller:
Leave the line in the header.html as:
<a class="navbar-brand" onclick="window.toggleNavbar()" style="cursor: pointer;">SB Admin 2</a>kinho commentedon Dec 21, 2016
I'm using
data-toggle="collapse" data-target=".navbar-collapse"in menu items.