Base solution for your next web application
Open Closed

How to collapse sidebar by default when navigating between pages? #9767


User avatar
0
dzungle created

Hello Support Team,

I want the left sidebar collapsed by default when users log in and navigating between pages. Is there any option to switch this feature on/off? Could you please show me how to collapse sidebar by default when navigating between pages?

Best Regards


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @dzungle

    Do you use Angular or jQuery version ?

    Thanks,

  • User Avatar
    0
    dzungle created

    Hi @ismcagdas,

    I am using Angular version 8.9.2.0.

    Thanks

  • User Avatar
    0
    dzungle created

    Hi @ismcagdas

    Could you please show me how to do this in Angular v8.9.2?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can basically run script below on each menu item click;

    document.body.classList.add('aside-minimize')

  • User Avatar
    0
    dzungle created

    Hi @ismcagdas,

    I have tried to put this script on the click function to navigate to new page, but it does not work. I also tried to put your script on the ngOnInit() of the new page, but it does not work either. Could you please show me more detail on where to put this script?

    Thank you

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I remembered a better way, you can directly modify this function https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/root-routing.module.ts#L49 and add "aside-minimize" class without a condition here.

  • User Avatar
    0
    dzungle created

    Hi @ismcagdas,

    Thank you for your support. It works now, but the class name is acctually 'kt-aside-minimize'.