views:

27

answers:

1

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

+1  A: 

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

Thank you...its works.I think the same will happen when we remove if condition also
Ajith