Using the jQuery mmenu plugin, I need to call a JavaScript function either after the menu has finished closing or simultaneously. In the documentation I can't see any suggestion for closing entire menu but only for closePanel. I need to insert in mmenu closing function another one (custom) to hide lightbox effect on the page.
<script type="text/javascript">
$(document).ready(function() {
$("#menu").mmenu({
"extensions": [
"theme-white"
],
"offCanvas": {
"zposition": "front"
},
"slidingSubmenus": false
});
$("#menu").show();
});
</script>
<script type="text/javascript">
function lightbox(){
(function($) {
// some stuff
})(jQuery);}
</script>
is there a way to bind another function after the plugin has been closed or better, when entire menu closing action?
I had the same exact question today and after some tinkering, this works for me. Bind to the opened/closed events like so:
$('#mmenu_id').data('mmenu').bind('opened', function () {
console.log('opened');
});
$('#mmenu_id').data('mmenu').bind('closed', function () {
console.log('closed');
});
you could try binding to the closing event
$('#mmenu').on('closing.mm', function() {
// do something
});
There is also a closed event too, so you can use which ever is appropriate
$('#mmenu').on('closed.mm', function() {
// do something
});
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