[SOLVED] [V1] dialog is open

Hi how do I know if a dialog is open?

You can check its element class, when opened it has “modal-in” additional class

1 Like

Thanks: I will give it a look soon and report

BTW… is there a way to know if ONE SPECIFIC PAGE has a modal dialog open and programmatically close it?

Actually scope being: in my app the back button close the app if user is in the main page. But would be more logic to close an eventual modal dialog instead if present…

Thanks again

Just check for $('.dialog.modal-in').length to know is there any dialogs opened

Cool thanks. Traveling now but will give it a try before end of the week and report. Thanks!

Hmmmm… not working:

myApp.confirm("ok?",
                    function () {
                        myApp.alert('You clicked Ok button');
                    },
                    function () {
                        //do nothing
                        myApp.alert('You clicked Cancel button');
                    }                
            );         

neither of the two following gets captured:

if ($$('.popup.modal-in').length > 0) { //some popup opened 
            myApp.closeModal();
            return;
        }
        
        if ($$('.dialog.modal-in').length > 0) { //some popup opened 
            myApp.closeModal(); alert('a');
            return;
        }

Tried this one and it works:

if ($$('.modal-in').length > 0) { //some modal opened 
            myApp.closeModal();
            return;
        }

Any possible downside in something so generic?

No, it is correct. I missed that you are using v1

1 Like