jqueryjquery-pluginsmmenu

Callback event when jQuery 'mmenu' opened


Using the jQuery mmenu plugin I need to call a JavaScript function after the menu has finished opening. I can't see from the API documentation how to do this using the plug-in API, so I'm thinking perhaps the only option is to observe the class name on the <html> element, which gains a class of mm-opened when the menu is opened. This feels a little 'hacky' though, so I wondered if anyone could see a way, within the bounds of the native API, to accomplish the required function call?

EDIT: Contrary to expectations the openPanel event doesn't fire when the menu is opened - it only fires when sub-menus are opened, so although this suggests it would do the job, it doesn't.

Many thanks.


Solution

  • Got it (not documented!):

    var api = $('#menu').data('mmenu');
    api.bind('opened', function () {
        console.log('opened');
    });