Tuesday, June 13, 2017

Yii CListView ajax load more

Below solution is works fine.
 
InfiniteScroll Extension Path : 

https://github.com/erikuus/Yii-Extensions/tree/master/widgets
 
Implementation:

<?php
        $this->widget('zii.widgets.CListView', array(
                    'dataProvider'=>$dataProvider,
                    'itemView'=>'/jobs/viewJobList',
                    'summaryText'=>false,
                    'emptyText'=>"<p> No Jobs!!!</p>",
                    'id'=>'ajaxJobListView',
                   'template' => '{items} {pager}',
                   'ajaxUpdate'=>true,
                    'pager' => array(
                        'class' => 'ext.infiniteScroll.IasPager',
                        'rowSelector'=>'.row',
                        'listViewId' => 'ajaxJobListView',
                        'header' => '',
                        'loaderText'=>Yii::t('app','Loading'),
                        'options' => array('history' => false, 'triggerPageTreshold' => 1,

 'trigger'=>Yii::t('app','Load More')),
                    ),
                'afterAjaxUpdate'=>"function(id, data) {
                    $.ias({
                        'history': false,
                        'triggerPageTreshold': 1,
                        'trigger': Yii::t('app','Load More'),
                        'container': '#ajaxJobListView',
                        'item': '.row',
                        'pagination': '#ajaxJobListView .pager',
                        'next': '#ajaxJobListView .next:not(.disabled):not(.hidden) a',
                        'loader': Yii::t('app','Loading')
                    });
                }",
            ));?>