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.
Got it (not documented!):
var api = $('#menu').data('mmenu');
api.bind('opened', function () {
console.log('opened');
});
You may search for .trigger(
on the source code:
https://raw.githubusercontent.com/FrDH/jQuery.mmenu/master/dist/js/jquery.mmenu.min.js
You will find the following events:
I believe those are it. Among them you can see the 'opened' and 'closed' events that will be useful for your case.
var api = self.$el.data("mmenu");
api.bind('close:finish', function() {
console.log('close');
});
api.bind('open:finish', function () {
console.log('open');
});
Thanks to ChezFre
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With