Shadowbox not working after ajax load data

最后都变了- 提交于 2019-12-11 01:56:27

问题


Shadowbox is unable to work after ajax load data. I tried to put in Shadowbox.init() to ajax load function and also in the php page. Nothing works. Shadowbox is working fine before ajax loaded data.

    $.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);
                    }

                }
            }); 

PHP page for html Result: (firefox can work with this code , chrome and IE not working with this code)

$html = "<script src='/static/js/shadowbox-3.0.3/shadowbox.js'></script>    
            <script>
                Shadowbox.init();
            </script>";

Does running shadowbox javascript caused the error? How do i make the shadowbox work?


回答1:


use

Shadowbox.init({ skipSetup: true }); Shadowbox.setup(); 

instead of Shadowbox.init();




回答2:


Got it work already.

Solution From http://shadowbox.1309102.n2.nabble.com/Documents-loaded-through-ajax-shadowbox-not-working-td1309124.html

We can only call Shadowbox.init(); 1 time. Therefor error occurs when i called Shadowbox.init(); in ajax load.



来源:https://stackoverflow.com/questions/17944397/shadowbox-not-working-after-ajax-load-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!