I'm using a great bootstrap 3 layout that use an "offcanvas" sidebar. All is working great on all screen size.
The HTML tag that triggered the sidebar is :
<a href="#" class="navbar-btn sidebar-toggle" data-toggle="offcanvas" role="button">
How could i trigger this event with jquery ?? Sometimes i need to toggle the sidebar on user event, somtimes i need to display the page with the sidebar hidden.
I try to trigger the click event with jquery but it does nothing as there isn't any onClick event on this tag...
Thanks for your help.
Use the collapse()
method that comes with Bootstrap. Something like
$('.sidebar-toggle').collapse();
should work.
See the link below for more info on collapse()
:
http://getbootstrap.com/javascript/#collapse-usage
Classname: "sidebar-collapse" is responsible for collapsing the sidebar.
For example:
<body id="bodyContainer" class="hold-transition skin-blue sidebar-mini sidebar-collapse">
This is for collapsed sidebar.
<body id="bodyContainer" class="hold-transition skin-blue sidebar-mini">
This is for non-collapsed sidebar.
So, basically you have to write jquery function to remove/include class "sidebar-mini"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With