Javascript 使用Jribble获取更多快照
所以,我一直在问自己的一个问题是,如何使用插件加载更多快照。遗憾的是,我在这个问题上找不到任何对我有意义的东西。我现在只使用JavaScript大约一个星期了,所以如果这看起来很笨拙,我很抱歉。我的代码如下:Javascript 使用Jribble获取更多快照,javascript,jquery,Javascript,Jquery,所以,我一直在问自己的一个问题是,如何使用插件加载更多快照。遗憾的是,我在这个问题上找不到任何对我有意义的东西。我现在只使用JavaScript大约一个星期了,所以如果这看起来很笨拙,我很抱歉。我的代码如下: $(document).ready(function () { // this is jRibbble example code if I recall correctly $.jribbble.getShotsByPlayerId('name', function (pl
$(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)
}
});
$(文档).ready(函数(){
//如果我没记错的话,这是JRIbble示例代码
$.jribble.getShotsByPlayerId('name',函数(playerShots){
var html=[];
$.each(playerShots.shots,函数(i,shot){
html.push(“”);
});
$('#grid').html(html.join('');
},{第1页,每页6});
$(窗口).on('load resize',函数(){
window.shotHeight=$('#grid li').outerHeight(true);
});
});
$(窗口)。滚动(函数(){
if($(窗口).scrollTop()+快照高度>$(文档).height()-$(窗口).height()){
//因此,在请求时间和用户到达页面底部之间有一个时间缓冲区(因此需要新的帖子)
}
});
我认为没有必要提及,如果有人至少能提供一些建议,我会多么感激
注意:由于我已经收到了反对票,我想解释一下,我想得到一些建议,而不是我太懒了,不想自己编写代码。所以,我找到了我问题的答案。我所要做的就是重新运行getShotsByPlayer,每次这样做时都增加“每页”。然后,只需合并两个数组。我早该知道的