JQuery 'mmenu' callback event

Using jQuery mmenu plugin I need to call a JavaScript function after the menu finishes opening. I don’t see the API documentation how to do this using the plugin API, so I think that perhaps the only option is to watch the class name on the <html> element that the mm-opened class gets when the menu opens. This seems a bit “hacked,” so I wondered if anyone could see a way within the built-in API to make the required function call?

EDIT: contrary to expectations, the openPanel event openPanel not fire when the menu is opened - it fires only when the submenu is opened, therefore, although this means that it will do the job, it is not.

Thank you very much.

+5
source share
2 answers

Received (not documented!):

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

You can find .trigger( in source code: https://raw.githubusercontent.com/FrDH/jQuery.mmenu/master/dist/js/jquery.mmenu.min.js

You will find the following events:

  • Init
  • update
  • setSelected
  • setPage
  • open
  • opening
  • is open
  • close
  • closing
  • closed
  • openpanel
  • openingpanel
  • openedPanel
  • closepanel
  • closingPanel
  • closedPanel

I believe that is all. Among them, you can see the "open" and "closed" events that will be useful for your business.

+6
source

All Articles