I need to make a call when the user is idle and passes the session time out that will close all Bootstrap modals. The modals being active are dependent on what the user is doing at the time so I would like to do something that's is all encompassing.
I tried:
$('.modal').modal('toggle');
When the time out occurs but my modals are still there.
Try this way :
$('.modal.in:visible').modal('hide');
This is how i got it working in my project without using any factory or additional code.
I have a timeout function that emits logout as
$rootScope.$emit('logout');
and the listener in my service is as follows:If you want to hide any other modals such as angular material dialog (
$mdDialog
) & sweet alert dialog's useangular.element('.modal-dialog').hide();
&angular.element('.sweet-alert').hide();
I don't know if this is the right approach , but it works for me.
Use the following code:
Also if you would like to do something if the modal is hidden then you can do this:
The correct answer is missing something vital.
The second line is vital if you want the users to use the page as normal.