Aadi
Aadi

Reputation: 7109

Jquery Popup with PHP

I am using a j query pop up for my web application.I need multiple pop up in same page for different purpose.I am using different id to invoke these. The problem is about Click out event!(out of popup). I am using the script as follows to close the layer

//Click out event!
$("#backgroundPopup").click(function(){

        disablePopup("#popupContact");
    disablePopup("#deleteConfirm");
});

My disablePopup function says as follows

//disabling popup with jQuery magic!
function disablePopup(divid){
    //disables popup only if it is enabled
    if(popupStatus==1){
        $("#backgroundPopup").fadeOut("slow");
        $(divid).fadeOut("slow");
        popupStatus = 0;
    }
}

it is not closing my second layer deleteConfirm.How can I solve this issue...Please help me

Upvotes: 0

Views: 397

Answers (1)

Rizky Ramadhan
Rizky Ramadhan

Reputation: 7770

of course, that because disablePopup() function is checking popupStatus == 1, and you set popupStatus = 0 at your first disablePopup("#popupContact"); , so when it get called the second time it cannot go to if(popupStatus==1){

FYI, popupStatus is global variable.

my suggestion is to put an attribute to your popup :

//disabling popup with jQuery magic!
function disablePopup(divid){
    //disables popup only if it is enabled
    if($(divid).attr('popupStatus') ==1){
        $("#backgroundPopup").fadeOut("slow");
        $(divid).fadeOut("slow");
        $(divid).attr('popupStatus','1')
    }
}

hope it works

Upvotes: 1

Related Questions