Off-canvas Menu In Wayne Corp Template - Question | JoomShaper

Off-canvas Menu In Wayne Corp Template

S

sandymikami

Template 1 year ago

Hi Joomshaper

With the off-canvas menu in the Wayne Corp template, I need to be able to click on top level menu items (URL #) and have the sub menu items open up. At the moment, the sub menu items only open up if you click directly on the left hand side arrow. It's too easy for people to click on just the menu item and think it's not working. What code do I need so that both the arrow and the menu item will open the sub menu when clicked?

Thanks

0
3 Answers
Ofi Khan
Ofi Khan
Accepted Answer
Support Agent 1 year ago #173091

Hello sandymikami

Please use this JavaScript to Template Options -> Custom Code -> Custom JavaScript

jQuery(function($) {
    $(document).on("click", ".menu-deeper", function(event) {
        if (event.target.classList.contains('menu-toggler')) return;
        if (event.target.children.length) {
            event.preventDefault();
            event.stopPropagation();
            $(this)
                .toggleClass("menu-parent-open")
                .find(">.menu-child")
                .slideToggle(400);
        }
    });
});

Best regards

0
S
sandymikami
Accepted Answer
1 year ago #173095

Perfect, thanks!

0
Ofi Khan
Ofi Khan
Accepted Answer
Support Agent 1 year ago #173096

You are welcome 😊

There is an update. Please use this JavaScript

$(document).on("click", ".menu-deeper", function(event) {
    if (event.target.classList.contains('menu-toggler')) return;
    const linkElement = $(this).find("a")[0];
    if (linkElement && linkElement.getAttribute("href") === "#") {
        event.preventDefault();
    }
    if (event.target.children.length) {
        event.stopPropagation();
        $(this)
            .toggleClass("menu-parent-open")
            .find(">.menu-child")
            .slideToggle(400);
    }
});
0