I’m using a collapsed navigation menu on a one-page layout. It’s the only navigation menu on the site and is common to both desktop and mobile layouts for consistency.
I am also using the following jquery from this support forum to close the menu after a link is chosen so the menu isn’t in the way of the page contents.
jQuery(function($) {
$(’.x-menu-collapsed .x-anchor’).on( “click touchstart”, function() {
$(’.x-off-canvas-close’).click();
});
});
That’s all working perfectly both on mobile and on the desktop.
The problem is that my menu has sub-menu headers and when the viewer clicks on those headers to expand the menu, the entire menu closes and they have to open it again to see the now expanded sub-menu.
Example:
Topic1 – #topic1
Topic2 – #topic2
Topic3 – # //this is just a header
Subtopic A – #topic3SubA
Subtopic B – #topic3SubB
Topic4 – #topic4
So if someone clicks on Topic3 to expand the submenu to get to Subtopic A, the whole menu closes and they have to reopen it to click on the Subtopics. I want to keep the menu close behaviour on Topics 1, 2 & 4 and Subtopic A & B, but NOT on Topic3.
The headers are created using just a # so they don’t effectively link anywhere, but just function as headers. I’m thinking I need to modify the jquery to ignore any link that is just # instead of #something. Is that correct? Is there an easy way of doing that or is there an entirely different approach that is better?
I’m developing this on my computer (i.e. localhost) so I can’t really provide access but I can provide screenshots or code snippets or anything else anyone might need to help me out.
Thanks so much in advance for any help!