来自$(window)的奇怪行为.load

时间:2016-04-29 13:56:05

标签: jquery

当用户连接而不是加载页面时,我通过socket.io发送大量数据,当div已经加载了我试图使用的数据$(window).load等到一切已加载。

如果我努力刷新网站,清除所有缓存,网站加载正常,一切都正常淡入,但在软刷新网站完成加载但没有任何淡入。

有什么想法吗?感谢

这是完整的代码减去不重要的位:

socket.on('websiteLoad', function(data) {
    $('#pot_players, #pot_players_pics, #wheelInfo, #wheelArrow, #all_pot_items, #prev_win, #luck_win, #itemCounter, #timeCounter').hide().promise().done(function() {

        // Load Pot Data
        $('#pot_players').load('headers/pot.php')
        // 4 more .load here
        $('#wheelArrow').html('<img src="images/fade.png">')

        // Load Chart Data
        for (i=0;i<data.allData.chartData.length;i++) {
            // Data
        }

        // Load timers
        if (data.allData.itemData == null) {
            $('#itemCounter').html('<div class="time-seconds">0 /</div> 50 Items')
            $('#timeCounter').html('starting in 50 seconds...')
        }
        else {
            $('#itemCounter').html('<div class="time-seconds">' + data.allData.itemData + ' /</div> 50 Items')
            $('#timeCounter').html('starting in 50 seconds...')
        }

        // Load Luckiest Data
        if(data.allData.luckiestData == null) {
            var luckCon = '<div class="holder-l"><h3>Luckiest Player</h3><div class="info-hold-l"><h4>No One</h4>  <br>won <span>0</span>&#x1f353;<br>With <span>0%</span> chance!</div><div class="image-hold-l"><a href="#"><div class="image-effect"><img src="" alt=""></div></a></div></div>';
        }
        else {
            var luckCon = '<div class="holder-l"><h3>Luckiest Player</h3><div class="info-hold-l"><h4>' + data.allData.luckiestData.name + '</h4>  <br>won <span>' + data.allData.luckiestData.winnings + '</span>&#x1f353;<br>With <span>' + data.allData.luckiestData.percentage + '%</span> chance!</div><div class="image-hold-l"><a href="' + data.allData.luckiestData.profileLink + '"><div class="image-effect"><img src="' + data.allData.luckiestData.pic + '" alt=""></div></a></div></div>';
        }
        $('#luck_win').html(luckCon)
    });

    $('.welcome').css("display", "block").delay(5000).fadeOut();

    $(window).load(function(){
        $('#pot_players, #pot_players_pics, #wheelInfo, #wheelArrow, #all_pot_items, #prev_win, #luck_win, #itemCounter, #timeCounter').fadeIn(1500);
        myChart.update();
    });
});

0 个答案:

没有答案