Im having a button to open a popup-windwow. By clicking on itself again, the popup-window should close (this one works). But after closing it is not possible to reopen the window. How can I fix this unbind-Problem?
//loading Popup
//0 means disabled; 1 means enabled;
var popupStatus = 0;
function loadPopup ($elem) {
//loads popup only if it is disabled
if(popupStatus==0){
$elem.fadeIn(300, function(){
//Closing popup by clicking the button
$("#popup-button").bind("click", function(){
disablePopup();
});
});
popupStatus = 1;
}
}
//disable popup
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$(".popup-background").fadeOut("slow");
$("#popup-wrapper").fadeOut("slow");
$("#popup-button").unbind("click", function(){
disablePopup();
});
popupStatus = 0;
}
}