Is there a callback or any other way to execute the function after jQuery mmenu has completed the activation of the plugin?

I run the plugin on click.

$('#activate_mmenu').on('click', function(){ $('#menu').mmenu(); }); 

Is there a way to link another function after activating the plugin?

something like that:

 $('#activate_mmenu').on('click', function(){ $('#menu').mmenu(function(){ alert('plugin is activated!'); }); }); 
+6
source share
2 answers

Mmenu launches its own events

 $("#nav") .mmenu() .trigger( "mmenu-created" ) ); 

more information is available here: http://mmenu.frebsite.nl/events.php

Edit: Deleted the wrong part of the code. You can trigger an event right after initializing mmenu.

+1
source
 $('#activate_mmenu').on('click', function(){ $("#menu") .mmenu() .on('init', function(){ console.log('init'); }) .trigger( "init" ); }); 

The documentation doesn't say a ton about custom events, but I got this to work. Then run it. As a result, you can simulate callbacks during initialization.

First, I created a custom event and bound it to the .mm namespace, as recommended in the docs, but that doesn't seem necessary.

+1
source

Source: https://habr.com/ru/post/956168/


All Articles