Cpagination and Ajax

hi i have problems regarding with pagination.

here is my code

for controller




    $dataProvider = new CActiveDataProvider('User', array(

            'pagination'=>array(

                    'pageSize'=>10,

            ),

    ));


    $this->render('users',array(

      'dataProvider'=>$dataProvider,

    ));  



for view users




$this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_user',

);



and for _user




<?php $viewid = $data->iduser; ?>

<tr id="tr<?php echo $viewid; ?>">

<td><?php echo CHtml::encode($data->idstatus0->type); ?></td>

<td><?php echo CHtml::encode($data->iduser_type0->type); ?></td>

<td><?php echo CHtml::encode($this->displayDate($data->date_added)); ?></td>

<td><?php echo CHtml::encode($this->displayDate($data->date_lastlogin)); ?></td>

<td><?php echo CHtml::ajaxLink($text, $this->createUrl('admin/deleteuser',array('id'=>$data->iduser)), array('success'=>"js:function(html){ $('#tr{$viewid}').remove(); }"), array('confirm'=>_t('Are you sure you want to delete this user?'), 'class'=>'delete-icon','id'=>'x'.$viewid)); ?></td>

</tr>



if i have 15 rows in a database it will only show 10 and will generate a pagination for next 5. The first 10 rows has no problem with the ajaxLink because the clientscript was generated but problem is the when I move to the next page, the ajaxLink is not working because its not generated by the pagination .

any idea? thanks

Generally I would advise you for ajax links and buttons to use separate jquery code and not the built in yii javascript. On the side why are you assigning a variable like


<?php $viewid = $data->iduser; ?>

when you can use


<tr id="tr<?php echo $data->iduser; ?>">

… just curious :)

I think you may need to use either the jQuery delegate() or on() function for this to work (depending on the version of jQuery you are using)

http://api.jquery.com/delegate/

http://api.jquery.com/on/

So you will need to modify your code to use one of these functions so that it can work on any dynamically created elements.