Reputation: 398
I have an angular-ui modal window, and, obviously, when I click outside the modal(backdrop) the modal closes.
However, I would like to change this behavior, for example, when I click on the backdrop, the popup window shows up with 2 buttons (OK and Cancel) and the modal will NOT close on Cancel.
The popup phase is easy, but I am not sure how to stop the modal from closing.
Could anybody help me with this, please? Thanks a lot!
Upvotes: 0
Views: 1321
Reputation: 5469
As Hurix mentioned, Give
backdrop : 'static'
in your modal options which will not close the modal window when backdrop is closed. Then apply a click event on backdrop:
$('.modal-backdrop').on('click', function(){
if (confirm('close modal') == true){
//dismiss your modal instance
} else {
//return
}
});
This click function will give a confirmation popup with ok
and cancel
button and you can handle whatever you want to do when they are clicked.
Upvotes: 2