我对Laravel和jQuery很新,所以这可能是一个愚蠢的问题。 我被卡住了,我不知道在jScroll的nextSelector部分写什么。 nextSelector应该包含到下一页的链接,我正在使用laravel的paginate()。我试图为帖子进行无限滚动。
这是我的home.blade.php,其中包含jScroll的帖子和脚本:
<div class="row scroll">
<div class="col-lg-9 col-lg-offset-1 col-md-10 col-lg-offset-1 col-sm-10 col-sm-offset-1 col-xs-10 col-xs-offset-1">
@foreach($posts as $post)
<div class="panel panel-default ag" id="{{$post->id}}">
<div class="panel-heading poststyle ">{{ $post->name }}</div>
<div class="panel-body poststyle">
{!! nl2br(e($post->depression)) !!}
</div>
<ul class="list-group">
<li class="list-group-item"></li>
<li class="list-group-item">
<button class="btn btn-info btn-xs option1 lc{{$post->id}}" data-idl="l{{$post->id}}" onclick="this.blur();" data-toggle="button" name="options" id="option1" autocomplete="off">
<span class="glyphicon glyphicon-thumbs-up"></span>
</button>
<span class = "poststyle"> {{ $post->like }} </span>
<button class="btn btn-success btn-xs optionx dc{{$post->id}}" data-idd="d{{$post->id}}" onclick="this.blur();" data-toggle="button" name="options" id="option1" autocomplete="off">
<span class="glyphicon glyphicon-thumbs-down"></span>
</button>
<span class = "poststyle"> {{ $post->dislike }} </span>
</li>
</ul>
</div>
<br>
@endforeach
{!! $posts->render()!!}
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('ul.pagination:visible:first').hide();
$('.scroll').jscroll({
loadingHtml: '<div class = "loading">  Loading...</div>',
debug: true,
autoTrigger: true,
nextSelector: '?',
contentSelector: 'div.scroll',
callback: function () {
$('ul.pagination:visible:first').hide();
}
});
});
</script>
这是我使用paginate()的控制器:
class NavController extends Controller
{
public function home()
{
$posts=Depress::orderBy('id','DESC')->paginate(5);
return view('home')->with('posts',$posts);
}
我在我不知道该做什么的地方放了一个问号(?)(nextSelector)。
有人请帮帮我......