1

i want's to add ajax loader in my clistview pagination links.

how is it possible in yii pagination.

Thanks.

aman
  • 135
  • 1
  • 12

1 Answers1

2

You have to create two js functions: first to show loader and second to hide it and pass them to CListView.

$this->widget('zii.widgets.CListView', array(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_post',   // refers to the partial view named '_post'
    'beforeAjaxUpdate' => 'function(id) { $(\'.loader\').show(); }'
    'afterAjaxUpdate' => 'function(id) { $(\'.loader\').hide(); }'
    'sortableAttributes'=>array(
        'title',
        'create_time'=>'Post Time',
    ),
));

Of course, you have to create div loader in html structure with image and position.

Here you have reference:

http://www.yiiframework.com/doc/api/1.1/CListView#beforeAjaxUpdate-detail http://www.yiiframework.com/doc/api/1.1/CListView#afterAjaxUpdate-detail

rzelek
  • 3,975
  • 1
  • 33
  • 35
  • @arekzelechowski is there anything similar for gridview in yii2.. I cant find any `beforePjaxUpdate` or `beforeAjaxUpdate` in yii2 gridview thank you – Mike Ross Sep 15 '15 at 05:55