为什么猫头鹰旋转木马没有装载一些时间

时间:2015-09-14 07:49:55

标签: jquery ajax html5 knockout.js owl-carousel

这里我从Ajax填充滑块信息,并且在刷新页面之后它的工作正常了一段时间我做了ajax调用并且它做了同样的但是Slider没有加载

            $.ajax({
            url: 'api/User/GetSportCategoryList',
            contentType: "application/json; charset=utf-8",
            beforeSend: function (e) {
                e.setRequestHeader("Authorization", "Basic b3BiYW5kOm9wYmFuZA==")
            },
            type: "get",
            success: function (data) {
                gTournamentList = data.tournamentBannerList;
                console.log($(".tournament-list-slider-element").html()); //First time no html content.
                           var len = gTournamentList.length;
        var htmlstring = '' ;
        for(var i=0;i<len;i++)
            {
            htmlstring += '<div class="item">' +
                '           <div class="headcol" style="cursor:pointer">' +
                '                <div class="headcolleft">' +
                '                    <div class="tourcol"> <img src ="'+gTournamentList[i].Image+'" height="100px" width="200px" alt="" >' +
                '                     </div>' +
                '                </div>' +
                '                <div class="headcolrig">' +
                '                    <div class="tourtxt">' + gTournamentList[i].TournamentName + '</div>' +
                '                </div>' +
                '              </div>' +
                '            </div>';
            }
        htmlstring += '';
        $(".tournament-list-slider-element").html(htmlstring);
        len = gTournamentList.length;
        var noOfElement = 0;
        switch (len) {
            case 1: noOfElement = 1;
                break;
            case 2: noOfElement = 2;
                break;
            case 3: noOfElement = 3;
                break;
            case 4: noOfElement = 4;
                break;
            default: noOfElement = 4;
        }

        $(".tournament-list-slider-element").owlCarousel({
            items: noOfElement, //10 items above 1000px browser width
            itemsDesktop: [1000, 3], //5 items between 1000px and 901px
            itemsDesktopSmall: [900, 3], // 3 items betweem 900px and 601px
            itemsTablet: [600, 2], //2 items between 600 and 0;
            itemsMobile: [320, 1] // itemsMobile disabled - inherit from itemsTablet option
        });
        // Custom Navigation Events
        $(".next3").click(function () {
            $(".tournament-list-slider-element").trigger('owl.next');
        })
        $(".prev3").click(function () {
            $(".tournament-list-slider-element").trigger('owl.prev');
        })

            }

刷新页面滑块变为空后,首次成功工作。怎么解决?请帮忙。

0 个答案:

没有答案