Cancel Modal Closing


Topic: Cancel Modal Closing

Preuss asked a year ago

Hey Guys,i want to cancel the closing of modals, if some condition is true. Example behavior for that are large inputs, when filling them and then accidently closing the modal, that could be really a mess. So is it possible to cancel the closing of the modal during the close event? This would give me the ability to inform the user, for example "All changes will be lost, close anyway?".

I know it would be possible by disabling background click and put these checks on buttons, but it would not be the best solution for me.

Thanks in advance.


I think that the best way to do that would be to block modal backdrop click and add document click listener with your own logic.

There is no built-in method for something like that.


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: Angular
  • MDB Version: 8.4.0
  • Device: Sony Vaio VPCF2
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No
Tags