I am using Angular UI $modal in my project http://angular-ui.github.io/bootstrap/#/modal
I don't want user to close the modal by pressing on backdrop. I want a modal can only be closed by pressing close button which I have created.
How do I prevent modal from closing ?
You can prevent closing of modal dialog by setting the beforeClose event argument cancel value to true. In the following sample, the dialog is closed when you enter the username value with minimum 4 characters. Otherwise, it will not be closed.
Data-keyword="false" is to prevent closing modal while clicking Esc button, while data-backdrop="static" , allows you keep modal pop-up opened when clicking on Gray area.
To prevent closing bootstrap modal when click outside of modal window we need add properties data-backdrop="static" and data-keyboard="false" to button which we are using to show modal window like as shown following.
While you creating your modal you can specify its behavior:
$modal.open({ // ... other options backdrop : 'static', keyboard : false });
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