Search code examples
javascripthtmljqueryadminlte

AdminLTE3 - how to close Control Sidebar instead of toggle


I am using AdminLTE3 as an admin theme in my project.

What I am trying to do is to find a JS code which can close right sidebar, called "Control Sidebar Plugin"

I know I can use this code to toggle (open/close) sidebar, but I need to close it instead of toggle.

<a href="#" data-widget="control-sidebar" id="my-toggle-button">Toggle Control Sidebar</a>

jQuery:

$("#my-toggle-button").ControlSidebar('toggle');

BTW: Manual of AdminLTE3 did not mention how to close it directly: https://adminlte.io/docs/3.0/javascript/control-sidebar.html


Solution

  • you can try this

    > html
    <aside class="control-sidebar control-sidebar-light">
    </aside>
    
    > js
    $('.control-sidebar').ControlSidebar('collapse');
    $('.control-sidebar').ControlSidebar('show');
    // or
    $('.control-sidebar').ControlSidebar('toggle');