简体   繁体   中英

Stop refresh modaless popup on button click if already open up

I have page where I'am opens a modaless popup on a button click Open Popup .

Scenario:

Initially when page opens up no popup is displaying, I click on button Open Popup , my modaless popup is opens up and I have filled some data on that popup and if I click again on "Open Popup" button of parent page then my popup gets refreshed.

Expected:

If my modaless popup is already open then on click on Open Popup button (of parent) instead of refresing the popup, focus should comes on already opened popup.

I'm trying to achieve this using jQuery or JavaScript .

What I have tried so far: On click on Open Popup , I'm trying to check if open popup has 'in' class then do not open popup like:

if ($('#NewPopup').hasClass('in')) {
                return false;
            }

But, this is not working. Any idea how can I achieve this?

I have found one solution which checks if jQuery dialog is already open or not.

Here I am checking if dialog is already opens up then do not open it again:

if (!$('.ui-dialog-content').dialog("isOpen")) {
            $("#" + options.id).dialog("open");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM