Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dismiss multiple (all) modals at once?

Is there a way to dismiss multiple modals or only one by one like this: Navigation.ModalPopAsync()?

like image 471
Bob Avatar asked Aug 04 '16 17:08

Bob


People also ask

Can I have multiple modals?

It is possible for multiple modals to contain more than two modals (hence our usage of the name multiple modals rather than the term double modals that many sources use).

How do you destroy a modal?

modal('dispose') is a function defined to destroy the modal. The modal remains a part of the DOM even after using . modal('dispose'), this function only destroys the current instance of the modal component.

What is data dismiss modal?

modal-header class is used to define the style for the header of the modal. The <button> inside the header has a data-dismiss="modal" attribute which closes the modal if you click on it. The . close class styles the close button, and the . modal-title class styles the header with a proper line-height.

How do I stop data dismissal modal?

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.


2 Answers

I've actually written something to pop all modals.

It works by first figuring out how many modals are active then by popping them.

And yes, as Rohit Vipin Mathews mentioned in his answer, PopModalAsync(false); will remove the animation.

// Get number of modals on the Navigation Stack
int numModals = Application.Current.MainPage.Navigation.ModalStack.Count;

// Pop each modal in the stack
for (int currModal = 0; currModal < numModals; currModal++)
{
    await Application.Current.MainPage.Navigation.PopModalAsync();
}
like image 139
Timothy James Avatar answered Nov 23 '22 18:11

Timothy James


For Modals you have to do one by one because its on the Modal Stack For Navigation Stack you can use Navigation.PopToRootAsync()

Also you can try not awaitthe Navigation.ModalPopAsync() and also pass animation as false.

You can find more details in this forum post- PopToRootAsync with Modal

like image 27
Rohit Vipin Mathews Avatar answered Nov 23 '22 19:11

Rohit Vipin Mathews