[英]Jribbble - How do I load 6 shots at a time
I'm a bit new to Javascript, but I've managed to get things to load to the page which is a start. 我对Java有点陌生,但是我设法将内容加载到页面上,这是一个开始。
I'm trying to load 6 "shots" to a page with this script, but it currently loads them all: 我正在尝试使用此脚本将6个“镜头”加载到页面上,但当前将它们全部加载:
<script type="text/javascript">
$(document).ready(function getDribbbleShots() {
$.jribbble.getShotsByPlayerId('abenjamin765', function (playerShots) {
var html = [];
$.each(playerShots.shots, function (i, shot) {
var str = (''+shot.description+'');
html.push('<div class="col-md-4"><div class="thumbnail"><a href="' +shot.image_url+ '" target="_blank">');
html.push('<img class="shot-image" src="' + shot.image_url + '" ');
html.push('alt="' + shot.title + '"></a>');
//html.push('<div class="caption"><h4>'+ shot.title +'</h4>');
//html.push('<div class="ellipsis">'+shot.description+'</div>');
html.push('<p class="imgTitle"><a href="'+shot.url+'" class="btn btn-primary">' + shot.title + '</a></p></div></div></div>');
});
$('.dribbble-feed').html(html.join(''));
//$( ".ellipsis p" ).addClass( "ellipsis" );
}, {page: 1, per_page: 9});
});
</script>
I also I want to introduce a "load more" button that will load 3 shots at a time. 我也想介绍一个“加载更多”按钮,一次可以加载3张照片。
Any help would be greatly appreciated :) 任何帮助将不胜感激 :)
If you use playerShots.shots.slice(0, 2)
, the loop will go through just the first three "shots." 如果使用
playerShots.shots.slice(0, 2)
,则循环将仅通过前三个“射击”。
Documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice 文档: https : //developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
As far as loading more, you'll want to save the result from the API response to a variable accessible by your code that shows more "shots." 至于要加载更多内容,您将希望将API响应中的结果保存到代码中,该变量可显示更多“快照”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.