我用的是无穷无尽的卷轴,用的是有页码的拉拉。我有8张记录,我的记录限制是4。分页工作很好。分页链接有2页(4 *4页)。但是现在我想使用无限滚动。
对于无限滚动,我使用的是https://github.com/infinite-scroll/infinite-scroll
我已经在视图页面中包含了jquery.infinitescroll.min.js。写剧本。,但向下滚动不会产生任何效果。
我的视图页面:
<div class="content" id="content">
@foreach($item['hits'] as $key => $data )
@include('general::partials.product-list')
@endforeach
</div>
{!!$item->render()!!}我的脚本:
<script type="text/javascript" src="{{ asset('/themes/'.Theme::getCurrent().'/js/jquery.infinitescroll.min.js') }}"></script>
<script type="text/javascript">
$(function() {
var loading_options = {
finishedMsg: "<div class='end-msg'>Congratulations! You've reached the end of the internet</div>",
msgText: "<div class='center'>Loading news items...</div>",
img: "/assets/img/ajax-loader.gif"
};
$('#content').infinitescroll({
loading: loading_options,
navSelector: "ul.pagination",
nextSelector: "ul.navigation a:first",
itemSelector: "#content div.cat-item"
});
});
</script>发布于 2016-03-11 07:44:21
当您试图执行脚本时,您的脚本似乎还没有加载。使用此结构:
$( document ).ready()只有在加载所有JS文件时,它才会运行代码。
https://stackoverflow.com/questions/35934755
复制相似问题