1

用整个代码编辑:第 17 行现在是 33。

我在http://www.javascriptlint.com中运行了这段代码,它说第 33 行缺少一个分号。我添加了它,但它破坏了一切。谁能帮我找出错误?

$(document).ready(function () {

    var $container = $('.row');

    $container.imagesLoaded(function () {
        $container.masonry({
            itemSelector: '.post',
            columnWidth: 1
        });
    });


    $container.infinitescroll({
        navSelector: '#page-nav',
        nextSelector: '#page-nav a',
        itemSelector: '.post',
        loading: {
            finishedMsg: "No more entries to load.",
            img: "http://static.tumblr.com/7wtblbo/hsDlw78hw/transparent-box.png",
            msgText: "Loading..."
        },
        debug: true,
        bufferPx: 5000,
        errorCallback: function () {
            $('#infscr-loading').animate({
                opacity: 0.8
            }, 2000).fadeOut('normal')
        },  
    },

    function (newElements) {
        var $newElems = $(newElements).css({
            opacity: 0
        });
        $newElems.imagesLoaded(function () {
            $newElems.animate({
                opacity: 1
            });
            $container.masonry('appended', $newElems, true);
        });
    });


    $(window).resize(function () {
        $('.row').masonry();
    });


    setTimeout(function () {
        $container.masonry({
            appendedContent: $(newElements)
        });
        /* repair audio players*/
        $('.audio').each(function () {
            var audioID = $(this).attr("id");
            var $audioPost = $(this);
            $.ajax({
                url: '/api/read/json?id=' + audioID,
                dataType: 'jsonp',
                timeout: 50000,
                success: function (data) {
                    $audioPost.append('\x3cdiv style=\x22background-color:white;height:30px\x22 class=\x22audio_player\x22\x3e' + data.posts[0]['audio-player'] + '\x3c/div\x3e');
                }
            });
        });


    }, 2000);
});
4

3 回答 3

3

去掉 , 第 16 行是错误的!
和第 17 行一样!

于 2012-04-14T21:11:22.883 回答
2

}, 2000).fadeOut('正常') ;

errorCallback: function () { 
    $('#infscr-loading').animate({ 
        opacity: 0.8 
    }, 2000).fadeOut('normal');
}  

更新:

$container.infinitescroll({ 
    navSelector: '#page-nav', 
    nextSelector: '#page-nav a', 
    itemSelector: '.post', 
    loading: { 
        finishedMsg: "No more entries to load.", 
        img: "http://static.tumblr.com/7wtblbo/hsDlw78hw/transparent-box.png", 
        msgText: "Loading..." 
    }, 
    debug: true, 
    bufferPx: 5000, 
    errorCallback: function () { 
        $('#infscr-loading').animate({ 
            opacity: 0.8 
        }, 2000).fadeOut('normal');
    }
});
于 2012-04-14T21:15:40.980 回答
0

进行以下更改:

  • 第 27 行:添加分号
  • 第 28 行:删除逗号

行号用于编辑的代码

于 2012-04-14T22:43:59.707 回答