Is there a way to dismiss multiple modals or only one by one like this: Navigation.ModalPopAsync()
?
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).
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.
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.
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.
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();
}
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 await
the Navigation.ModalPopAsync()
and also pass animation as false.
You can find more details in this forum post- PopToRootAsync with Modal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With