Close mobile menu?

2 replies · opened Dec 21, 2016

EestatianDec 21, 2016

Hi,

I am using an item in the menu to open a modal contact form, inspired by the contact-5.html example page:


    
        
- [Contact us](#)
    

(My other menu items are left out for clarity and brevity.)

This works perfectly. However, on a mobile device (where the menu pops open after clicking the hamburger symbol) the menu remains open underneath the contact form and stays open after the form is submitted.

How can I have the menu close automatically when the contact form menu item is clicked?

  • John.
EestatianDec 22, 2016

The following JavaScript seems to do the trick in my case, but comments are still appreciated:

$("#primary-menu a").click(function() {
    if ($("body.primary-menu-open").length > 0) {
        $("#primary-menu > ul").toggleClass("show");
        $("body").toggleClass("primary-menu-open");
    }
});
SSemicolon WebSTAFFDec 23, 2016

Hello,

This is absolutely fine. However, you can also consider using the following code which closes the Primary Menu as soon as the Modal Opens:

jQuery('#myModal').on('shown.bs.modal', function () {
	jQuery("#primary-menu > ul").toggleClass("show", false);
	jQuery("body").toggleClass("primary-menu-open", false);
})

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