I think you simply forgot to render the paginator using {!! $articles->render() !!}, that's why jScroll can't find the correct link to get data from and tries to acces /undefined
Aug 27, 2015
26
Level 55
Larval and jScroll
When scrolling to the bottom of the page an error is thrown.
"Failed to load resource: the server responded with a status of 404 (Not Found). mydomain.com/undefined"
I am using jScroll, the pagination links are hidden but the content from the next page isn't loaded.
ArticlesController controller
public function index()
{
$articles = Article::latest('published_at')->simplePaginate(4);
return view('articles.index', compact('articles'));
}
index.blade.php view
<div class="scroller">
@foreach ( $articles as $article )
<div class="row">
<article class="item">
<div class="article-background-pattern"
style='background-image: {{ $article->header_image_path }}'></div>
<div class="card">
<div class="card-block">
<h3 class="article-title">{{ $article->title }}</h3>
<div class="article-body">
<p class="text-justify">{{ $article->body }}</p>
</div>
</div>
<p class="card-text card-footer text-right">
<small class="text-muted"><i
class="fa fa-fw fa-clock-o"></i> {{ $article->published_at->diffForHumans() }}
</small>
</p>
</div>
</article>
</div>
@endforeach
<div class="row">
{!! $articles->render() !!}
</div>
</div>
...
<script src="/js/jquery.jscroll.min.js"></script>
<script>
$(document).ready(function(){
$('ul.pager:visible:first').hide();
$('div.scroller').jscroll({
debug: true,
autoTrigger: true,
nextSelector: 'li a[rel="next"]',
contentSelector: 'div.scroller',
callback: function() {
$('ul.pager:visible:first').hide();
}
});
});
</script>
jScroll can be downloaded from here
Please or to participate in this conversation.
