tim1mw

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Overriding confusing submenu behaviour in mobile mode #72129
    tim1mw
    Participant

    I think I’ve answered my own question, replacing the code from frontend.js in my earlier post with the following achieves the behaviour I’m looking for:

    /* Close mobile menu on click/tap */
    jQuery(‘body’).on(‘click’,’#mobile-nav a’, function(evt) {
    var anchor = jQuery(evt.target).parent();
    if (typeof anchor.attr(“href”) == “undefined” || anchor.attr(“href”) == “#”) {
    var li = anchor.parent();
    var buttons = li.children(“button”);
    buttons.click();
    } else {
    jQuery(‘#nav-cancel i’).trigger(‘click’);
    }
    });

    In my opinion this is far less confusing for the use that simply closing the mobile menu if a submenu link that doesn’t have it’s own target is clicked. Any chance of this patch being integrated back into the official version?

    in reply to: Overriding confusing submenu behaviour in mobile mode #72128
    tim1mw
    Participant

    Well I have a partial fix for my problem, putting the following into a custom.js file loaded in my site header will prevent a specific menu item from closing the menu when tapped. You do need to hunt out the menu id from the page source, but that will rarely change so I can live with that if necessary:

    var menu_1 = document.getElementById(“menu-item-964”);
    if (menu_1 != null) {
    menu_1.addEventListener(“click”, function(evt) {evt.stopImmediatePropagation();});
    }

    Digging into the septera code, the following in resources/js/frontend.js , function septera_initnav :

    /* Close mobile menu on click/tap */
    jQuery(‘body’).on(‘click’,’#mobile-nav a’, function() {
    jQuery(‘#nav-cancel i’).trigger(‘click’);
    });

    Seems to be responsible for the event that closes the menu, disabling this kills menu closing altogether. I’m guessing that changing the logic here might enable this trigger to either close the menu in the event that a link with a target is clicked or open the submenu. Any advice on how to trigger the display of a submenu would be much appreciated!

Viewing 2 posts - 1 through 2 (of 2 total)