• Resolved JapeNZ

    (@japenz)


    Hi there,
    I’m using the WP Bottom Menu plugin which has an option to add an onclick event for custom menu items.

    I can’t for the life of me work out what the onclick code should be to get the sidebar to toggle.

    Sidebar ID:?#ocs-mobile-menu?? Trigger Classes:?.ocs-toggle-mobile-menu?.ocs-open-mobile-menu?.ocs-close-mobile-menu

    I managed to get the fly cart I use to trigger using ‘woofc_toggle_cart();’ but using a similar format for the sidebar doesn’t seem to work.

    Any help you can offer would be very much appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @japenz

    The events are automatically attached to any elements who have the trigger classes, where “toggle”, “open” and “close” stand for the actual action of the trigger. This is the recommended way as it included touch and responsive support etc.

    The method you mention involves a Javascript action instead of a CSS class.
    This will ignore any settings for this sidebar like disabling on larger screens etc.
    If you really want to use this method you can check the JS API:

    Docs: https://github.com/JoryHogeveen/off-canvas-sidebars/wiki/JavaScript-API
    Code example: https://github.com/JoryHogeveen/off-canvas-sidebars/blob/master/js/off-canvas-sidebars.js#L274-L288

    Quick example:

    ocsOffCanvasSidebars.slidebarsController.toggle( 'ocs-mobile-menu' );

    Cheers, Jory

    Thread Starter JapeNZ

    (@japenz)

    Hi @keraweb,

    Thank you so much, the code worked perfectly!

    Unfortunately I didn’t realise the menu wouldn’t have parent and children drop downs or any styling by default.

    Is there a guide for how to impliment that sort of thing anywhere?

    Thanks again for all your help!

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @japenz

    Depending on your theme, the sidebar indeed doesn’t include CSS.

    There are many ways to make this work. I can imagine using Blocks in your sidebar would work for example since I believe WP blocks don’t prefix their classes. Bootstrap or other CSS frameworks might help you as well.

    This plugin only provides the functionality, not the design/layout, simply because each WordPress installation is different and I simply cannot accommodate all themes. You can always ask your theme author or a developer for help.

    Cheers! Jory

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP Bottom Menu onclick event’ is closed to new replies.