在ajax加载数据后,Shadowbox无法工作。 我试图将Shadowbox.init()放入ajax加载函数,也放在php页面中。什么都行不通。在ajax加载数据之前,Shadowbox正常工作。
$.ajax({
type:"post",
url: url1,
data: {offset:offset},
dataType: "html",
timeout: 10000,
success:function(data) {
Shadowbox.init();
if(data == 0){
$("#nodeal").show();
$(".more_deals").hide();
$("#nomore").val(1);
$('#loadimage').hide();
}else {
Shadowbox.init();
$("#nodeal").hide();
$(".more_deals").hide();
$('.loadmoredeals').append(data);
$('#loadimage').hide();
}
},
error:function(request, status, err) {
if(status == "timeout") {
gotoagain(offset);
}
}
});
html的PHP页面结果:( firefox可以使用此代码,chrome和IE无法使用此代码)
$html = "<script src='/static/js/shadowbox-3.0.3/shadowbox.js'></script>
<script>
Shadowbox.init();
</script>";
运行shadowbox javascript会导致错误吗?我如何使影子箱工作?
答案 0 :(得分:2)
使用
Shadowbox.init({ skipSetup: true }); Shadowbox.setup();
而不是
Shadowbox.init();
答案 1 :(得分:1)
已经有了它。
的解决方案我们只能调用Shadowbox.init(); 1次。因为我调用了Shadowbox.init();在ajax负载。