【发布时间】:2016-01-18 05:40:13
【问题描述】:
我已成功从 Controller 返回数据
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"
});
});
});
[] 部分在页面底部创建,但无限滚动不起作用。此外,我在控制台中没有收到任何日志或错误。
【问题讨论】:
-
嗯,在 cmets 中描述了这些选择器是什么。
div.navigation是您的导航(您没有,但您可以像$posts->render()一样输出它)。itemSelector是一个项目的选择器(在你的情况下:div.col-md-4。考虑添加另一个类,如post)。 -
我编辑了我的问题并按照您所说的添加了课程,但是,我仍然无法在我的大脑中连接它们。可以给我看看吗?
-
在此处查看我的无限滚动插件以进行 L5 分页 stackoverflow.com/questions/31853472/…
标签: javascript jquery html laravel infinite-scroll