我在bxslider中遇到问题与弹出窗口有冲突

时间:2014-11-17 13:19:53

标签: popup carousel bxslider

我正在设计旋转木马。问题是它仍然是隐藏的。当我在浏览器中执行检查元素时,它会正确显示。

这是一个链接http://jsfiddle.net/dzvrrbyr/

JS:

$('#choose-image').bxSlider({
    slideWidth: 160,
    minSlides: 3,
    maxSlides: 3,
    moveSlides: 1,
    pager: false,
    slideMargin: 6 

});



jQuery(function($) {

$("button.BrowsePopup").click(function() {
        loading(); // loading
        setTimeout(function(){ // then show popup, deley in .5 second
            loadPopup(); // function show popup 
        }, 500); // .5 second
return false;
});

/* event for close the popup */
$("div.close").hover(
                function() {
                    $('span.ecs_tooltip').show();
                },
                function () {
                    $('span.ecs_tooltip').hide();
                }
            );

$("div.close").click(function() {
    disablePopup();  // function close pop up
});

$(this).keyup(function(event) {
    if (event.which == 27) { // 27 is 'Ecs' in the keyboard
        disablePopup();  // function close pop up
    }   
});

$("div#backgroundPopup").click(function() {
    disablePopup();  // function close pop up
});

$('a.livebox').click(function() {
    alert('Hello World!');
return false;
});


 /************** start: functions. **************/
function loading() {
    $("div.loader").show();  
}
function closeloading() {
    $("div.loader").fadeOut('normal');  
}

var popupStatus = 0; // set value

function loadPopup() { 
    if(popupStatus == 0) { // if value is 0, show popup
        closeloading(); // fadeout loading
        $("#BrowsePopup").fadeIn(0500); // fadein popup div
        $("#backgroundPopup").css("opacity", "0.7"); // css opacity, supports IE7, IE8
        $("#backgroundPopup").fadeIn(0001); 
        popupStatus = 1; // and set value to 1
    }   
}

function disablePopup() {
    if(popupStatus == 1) { // if value is 1, close popup
        $("#BrowsePopup").fadeOut("normal");  
        $("#backgroundPopup").fadeOut("normal");  
        popupStatus = 0;  // and set value to 0
    }
}
/************** end: functions. **************/
});

的CSS:

#BrowsePopup {
     font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
    background: none repeat scroll 0 0 #FFFFFF;
    /* border: 10px solid #ccc; */
    /* border-radius: 3px 3px 3px 3px; */
    color: #333333;
    display: none;
    font-size: 14px;
    left: 0;
    position: fixed;
    top: 96px;
    width: 576px;
    z-index: 999;
    left: 444px;
    margin-left: -445px;
}
div.loader {
    background: url("../img/loading.gif") no-repeat scroll 0 0 transparent;
    height: 32px;
    width: 32px;
    display: none;
    z-index: 9999;
   /*  top: 50%;
    left: 50%; */
    top: 320px;
    left: 566px;
    position: absolute;
    margin-left: -50px;
}
.small-close-icon{
    background: url("../img/small-close-icon.png") no-repeat scroll 0 0 transparent;
    cursor: pointer;
    height: 15px;
    position: absolute;
    width: 14px;
}
span.ecs_tooltip {
    background: none repeat scroll 0 0 #000000;
    border-radius: 2px 2px 2px 2px;
    color: #FFFFFF;
    display: none;
    font-size: 11px;
    height: 16px;
    opacity: 0.7;
    padding: 4px 3px 2px 5px;
    position: absolute;
    right: -62px;
    text-align: center;
    top: -51px;
    width: 93px;
}
span.arrow {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 7px solid #000000;
    display: block;
    height: 1px;
    left: 40px;
    position: relative;
    top: 3px;
    width: 1px;
}
div#popup_content {
    /* margin: 4px 7px; */
}
.content-popup-heading {
    padding: 20px 45px;
    background: #e6e6e6;
}
.content-popup-heading h2 {
    margin: 0;
    font-weight: normal;
    font-size: 22px;
    color: #f08006;
}
.content-popup-content {
    padding: 20px 45px;
}

#backgroundPopup {
    z-index:70;
    position: fixed;
    display:none;
    height:100%;
    width:100%;
    background:#000000;
    top:0px;
    left:0px;

}

1 个答案:

答案 0 :(得分:0)

您似乎错过了添加css文件

这是一个有效的fiddle

我稍微修改了一下代码。我已将滑块代码移到loadpopup函数

最终loadpopup函数看起来像

function loadPopup() { 
    if(popupStatus == 0) { // if value is 0, show popup
        closeloading(); // fadeout loading
        $("#BrowsePopup").fadeIn(0500); // fadein popup div
        $("#backgroundPopup").css("opacity", "0.7"); // css opacity, supports IE7, IE8
        $("#backgroundPopup").fadeIn(0001); 
        popupStatus = 1; // and set value to 1
        if(typeof window.slider == "undefined"){
            window.slider = $('#choose-image').bxSlider({
                slideWidth: 160,
                minSlides: 3,
                maxSlides: 3,
                moveSlides: 1,
                pager: false,
                slideMargin: 6
            });
        }
    }   
}