Angular UI Bootstrap Modal - how to prevent user interaction
Asked Answered
S

2

21

In my current usecase, I am trying to use angular-ui modal window to show the progress of calculations that we do in a background process which we disable on completion.

All works well. I just want to disable user from clicking any of element in background.

Any idea how can we do this?

Sigmund answered 4/12, 2013 at 9:14 Comment(0)
F
35

You can pass the following options, when opening a modal window, to prevent users from closing the window:

  • backdrop: 'static' - top prevent users from closing a modal on backdrop click
  • keyboard: false - so users can't close a window by pressing ESC

Full documentation here: http://angular-ui.github.io/bootstrap/#/modal

Favorite answered 6/12, 2013 at 12:22 Comment(0)
H
4

I just want to add an example with code and extend pkozlowski.opensource answer, Check this example:

    var modalInstance = $modal.open({
        templateUrl: '/views/registration/loginModal.html',
        controller: LoginModalInstanceCtrl,
        windowClass: 'login-modal-window',
        resolve : { 
          credentials : function(){ return {email :'', password:''}; }
        },
        backdrop: 'static', /*  this prevent user interaction with the background  */
        keyboard: false
      });

      modalInstance.result.then(function (res) {

      }, function () {
         /*  cancel */
         $state.go('home');
  });
Historiography answered 22/8, 2014 at 21:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.