kop / yii2-scroll-pager

Infinite AJAX scrolling for Yii2 ListView widget
https://kop.github.io/yii2-scroll-pager/
MIT License
180 stars 63 forks source link

There is load more click changes Url but not the containt of list view #44

Closed hitesh2088 closed 8 years ago

hitesh2088 commented 8 years ago

I have use the pager and list view widget with your extension but while clicking on load more it changes the url but the containt remains the same not loading more items... view code

 <?= 
              ListView::widget([
      'dataProvider' => $listDataProvider,
       'itemOptions' => ['class' => 'item'],
      'options' => [
                    'tag' => 'div',
                    'class' => 'list-wrapper',
                    'id' => 'list-wrapper',
                    ],
       'layout' => "{items}\n {pager}",  
       'itemView' => function ($model, $key, $index, $widget) {
        return $this->render('_list_item',['model' => $model]);

        // or just do some echo
        // return $model->title . ' posted by ' . $model->author;
    },
    'pager' => ['class' => \kop\y2sp\ScrollPager::className()]

              ]);

            ?>

The data provider in controller send data with below code

$pages = new Pagination(['totalCount' => $query->count()]);

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 3,
                //'pageCount'=> $pages, 
            ],
        ]);
kop commented 8 years ago

Hi @hitesh2088, and sorry for late response.

Your problem is invalid usage. You changed list view container class from .list-view to .list-wrapper. You now need to let ScrollPager know about this change:

'pager' => [
    'class' => \kop\y2sp\ScrollPager::className(),
    'container' => '.list-wrapper',
    'paginationSelector' => '.list-wrapper .pagination'
]