After adding infinite scrolling in my web page I found sometimes it's showing same row on another pages. I have used following code-
<?php $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
'contentSelector' => '#posts',
'itemSelector' => 'div.post',
'loadingText' => 'Loading...',
'donetext' => 'Data loading end',
'pages' => $pages,
)); ?>
How do I disable repeating same row?
Infinite scroll ( and yii-infinite scroll) stops querying the server when it it hits a 404 error. on the next page. Yii framework keeps returning the last results for page numbers greater than what the result has.
This is why you keep seeing duplicated rows at the end of the results.. to prevent this add this piece of code to your corresponding action in your controller.
if(isset($_GET['Model_page'])){
if($model->search()->pagination->pageCount < $_GET['Model_page']+1){
throw new CHttpException(404,'No More results');
}
}
Where Model_page
is to be substituted with Post_page
etc depending on your model name and $model->search()
is your dataProvider
, if you have some other dataProvider
please use that directly after it has been declared.