Open mmenu to a submenu

964 Views Asked by At

Is it possible to add a class such as “Selected” to an

  • element to automatically open a submenu from an on page click. I can add the class with jQuery, but it doesn’t seem to open the submenu like I want it to. I am guessing that is because the menu is already drawn before the class is appended. So, I guess my next question is, if this is the case is there a way to refresh the menu after I add the class of “Selected” so that the submenu automatically opens?

    Here is the code I am using to trigger the menu and add the class…

    $(document).ready(function () {
            $("#jobs-search").click(function() {
                $('#menu-left li#search-jobs').addClass('Selected');
                $("#menu-left").trigger("open.mm");
            });
        });
    

    The function adds the class, but it does not open the submenu like I want it to. Is this possible?

  • 1

    There are 1 best solutions below

    0
    On

    just put the class "mm-opened" to the list item you want to expand. you can add the class after the mmenu is initialised. the submenu opens automatically - no need to refresh ;)