I have a page with multiple <dialog>
elements, which I open as modal using their showModal() methods.
I want to detect whether any of them is currently opened from Javascript (since some event handlers shouldn’t trigger when a modal is opened). Is it possible to check if modal is currently opened? Maybe through existance of dialog::backdrop
or checking someway for inertness of non-modal content?
2
Answers
When dialog is opened as modal, it gets CSS pseudo-class :modal - so it can be queried with selector:
You can use Garnish.Modal.visibleModal to check if a modal is visible and which one.
Garnish Model