2014-10-03 44 views
-1

因此,我一直在問自己的一個問題是如何使用jRibbble插件加載更多鏡頭。可悲的是,我無法找到任何關於這個問題的東西,這對我來說很有意義。我現在只用了一個星期左右的JavaScript,所以我很抱歉,如果這看起來很笨拙。到目前爲止我的代碼如下:使用Jribbble獲取更多鏡頭

$(document).ready(function() { 
    // this is jRibbble example code if I recall correctly 
    $.jribbble.getShotsByPlayerId('name', function (playerShots) { 
     var html = []; 

     $.each(playerShots.shots, function (i, shot) { 
      html.push('<li><a href="' + shot.url + '">'); 
      html.push('<img src="' + shot.image_url + '" alt="' + shot.title + '"></a></li>'); 
     }); 

     $('#grid').html(html.join('')); 
    }, {page: 1, per_page: 6}); 

    $(window).on('load resize', function() { 
     window.shotHeight = $('#grid li').outerHeight(true); 
    }); 
}); 

$(window).scroll(function() { 
    if ($(window).scrollTop() + shotHeight > $(document).height() - $(window).height()) { 
     // so that there's a time buffer between the time of request and when the user reaches the bottom of the page (and thus expects new posts) 
    } 
}); 

我不認爲這是有必要提一下,我會是多麼感激,如果有人可以至少提供一些指引。

注意:因爲我已經收到了一個downvote,我想解釋一下,我想獲得一些指針,而不是我懶得編碼自己。

回答

0

所以,我找到了我的問題的答案。我所要做的就是重新運行getShotsByPlayer,每次增加'per_page'。然後,只需合併兩個數組。我應該知道這一點。