Open | Hide Side Panel using strictly a script

3 replies · opened Mar 11, 2022

PPavelRomeroMar 11, 2022

Hello:

I've seen examples where adding the side-panel-trigger class to a button can open | close the Side Panel, if I strictly need it to be through a JQuery or Javascript script, how could I do it?

Regards
Pavel

SSemicolon WebSTAFFMar 13, 2022

Hello,

Thanks for your Patience!

For the jQuery Code, you can use the following code:
[ch_pre type="js"]jQuery('body').toggleClass("side-panel-open");[/ch_pre]

To just Open:
[ch_pre type="js"]jQuery('body').toggleClass("side-panel-open", true);[/ch_pre]

To just Close:
[ch_pre type="js"]jQuery('body').toggleClass("side-panel-open", false);[/ch_pre]

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

PPavelRomeroMar 15, 2022

Thank you very much. One additional question, the Side Panel automatically closes when you press on either side of the screen. How to avoid this behavior so that it is only closed by pressing a button located inside the Side Panel itself?

Regards
Pavel

SSemicolon WebSTAFFMar 17, 2022

Hello,

Find and delete the following line of code in the js/functions.js File:
[ch_pre type="js"]if (!$(event.target).closest('#side-panel').length) { $body.toggleClass('side-panel-open', false); }[/ch_pre]

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard