我成功地从控制器无限滚动jQuery和Laravel 5 PAGINATE
public function index()
{
$posts = Post::with('status' == 'verified)
->paginate(30);
return view ('show')->with(compact('posts'));
}
返回的数据还有,我成功地展示在我看来一切:
<div id="content" class="col-md-10">
@foreach (array_chunk($posts->all(), 3) as $row)
<div class="post row">
@foreach($row as $post)
<div class="item col-md-4">
<!-- SHOW POST -->
</div>
@endforeach
</div>
@endforeach
{!! $posts->render() !!}
</div>
一切工作很好直到现在。
但是,我根本没有得到官方文档。什么是'div.navigation
'和'#content div.post
'?他们应该在我的情况?
段从文档:
$('#content').infinitescroll({ navSelector : "div.navigation", // selector for the paged navigation (it will be ?>hidden) nextSelector : "div.navigation a:first", // selector for the NEXT link (to page 2) itemSelector : "#content div.post" // selector for all items you'll retrieve });
编辑:我的JavaScript到目前为止
$(document).ready(function() {
(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.item"
});
});
});
的〔< [1] 2] 3]>]部分在页面的底部创建,但无限滚动不起作用。另外,我在控制台中没有记录或错误。
好吧,它在评论中描述了那些选择器。 'div.navigation'是你的导航(你没有,但是你可以像'$ posts-> render()')那样输出它。和'itemSelector'是一个项目的选择器(在你的情况下:'div.col-md-4'。想想为'post'添加另一个类)。 – Tim
我按照你的说法编辑了我的问题并添加了课程,但是,我仍然无法将它们连接在我的大脑中。你能告诉我吗? – senty
请参阅我的infinit滚动插件L5分页这里http://stackoverflow.com/questions/31853472/laravel-infinite-scroll-for-pagination-output –