Now easy with the latest version:
http://materializecss.com/modals.html
You can customize the behavior of each modal using these parameters. For example, you can call a custom function that will be run when the modal is rejected. To do this, simply put your function in the initialization code, as shown below.
$('.modal').modal({ dismissible: true, // Modal can be dismissed by clicking outside of the modal ready: function(modal, trigger) { // Callback for Modal open. Modal and trigger parameters available. alert("Ready"); console.log(modal, trigger); }, complete: function() { alert('Closed'); } // Callback for Modal close } );
UPDATE: I originally answered it a long time ago, but recently @JackRogers reviewed it, and here is the code, please use it if it works :) I do not have working settings for testing it.
$('.modal').modal({ dismissible: true, // Modal can be dismissed by clicking outside of the modal onOpenEnd: function(modal, trigger) { // Callback for Modal open. Modal and trigger parameters available. alert("Ready"); console.log(modal, trigger); }, onCloseEnd: function() { // Callback for Modal close alert('Closed'); } } );
source share