Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material Modal - Get notified when modal closes #105

Open
Seyphaton opened this issue Jan 24, 2020 · 2 comments
Open

Material Modal - Get notified when modal closes #105

Seyphaton opened this issue Jan 24, 2020 · 2 comments

Comments

@Seyphaton
Copy link

Hi,

I am currently struggling with the material modal window.
I need to trigger and stop some events as soon as someone closes the modal window.

Options that came to my mind:

  • MutationObserver to watch for the classes of the modal (open yes /no). This solution is not optimal since its not compatible with all browser versions.
  • Listen to outside clicks, key presses (ESC) and clicks on the close button to get notified. Not very satisfying as well.

Is it possible to solve this straightforward?

Best regards for your help!

@bilbaoba
Copy link
Contributor

If you look at the documentation : https://materializecss.com/modals.html#options, there is onCloseStart and onCloseEnd options.
Maybe it can help you.

@Seyphaton
Copy link
Author

Seyphaton commented Feb 2, 2020

Thanks for the hint, but I can't get it to work:

shinyjs::runjs("
   $('#modalTrip').modal('open',{
        dismissible: false, 
        onOpenEnd: function(modal, trigger) { //Callback after opened
          alert('ready');
        },
        onCloseEnd: function() { // Callback for Modal close
          alert('Closed');
        }
      }
    );

   ")

It opens, but its still dismissible and the callbacks don't trigger
Any Idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants