StrugglingCoder
StrugglingCoder

Reputation: 5021

Method call while closing a bootstrap modal popup

I am trying to redirect to a page while closing a modal popup. But that's not happening.

I am trying to redirect to a page either by using

state.go() or by location.path().

Here is the confirmation pop - up code in angular :

function modalMessage($rootScope,result) {
    $rootScope.FinalMessage = result.finalMessage;
    $rootScope.ReasonOrTransKey = result.ReasonOrTransKey;
    $rootScope.ConfirmationMessage = result.ConfirmationMessage;

    //Finds element with attribute iConfirmationModal
    angular.element("#iConfirmationModal").modal();
}

When the user clicks on the close() button I want put my redirect code.

enter image description here

Upvotes: 2

Views: 90

Answers (2)

MarkoCen
MarkoCen

Reputation: 2324

since the jqLite does not support modal method, you should use $ instead of angular.element

Plunker

function modalMessage($rootScope,result) {
     $rootScope.FinalMessage = result.finalMessage;
     $rootScope.ReasonOrTransKey = result.ReasonOrTransKey;
     $rootScope.ConfirmationMessage = result.ConfirmationMessage;

     //Finds element with attribute iConfirmationModal
     $("#iConfirmationModal").modal();
     $("#iConfirmationModal").on('hidden', function(){
        $timeout(function(){
            $state.go(...)
        })
     })
}

Upvotes: 2

DK3
DK3

Reputation: 403

This event is fired when the modal has finished being hidden from the user (will wait for css transitions to complete).

angular.element("#iConfirmationModal").on('hidden', function () {
  // do something…
})

http://getbootstrap.com/2.3.2/javascript.html#modals

Upvotes: 0

Related Questions