Cgridview Problem + Ajax Pagination

Hi! First of all I’m a noob when it comes to yii… I’m working on an application where the user choose columns from a DB table, and it get displayed in a GridView via fancybox. I have a button that sends an ajaxreq, and the controller action that recieves it creates a CSqlDataProvider and renders the gridview partially in a div.

This works nicely the first time, but if the user changes the parameters (adds columns) and clicks the "preview"-button again. The gridview seems to bind duplicate events on pagination/sort etc, as it sends multiple (one for each time I click the preview-button) ajax-requests if I click on another page in the gridview. The action:


public function actionPreview(){ $data=new CSqlDataProvider($stmt, array(

				'totalItemCount'=>$count,

				'keyField' => $key,

				'sort'=>array(

				'attributes'=>array($key,),

				),

				'pagination'=>array(

						'pageSize'=>10,

				),

		));


    $this->renderPartial('index4', array('data'=>$data),false,true);



And the view (index4)


$this->beginWidget('zii.widgets.grid.CGridView', array(

		'id'=>'grid',

		'dataProvider'=>$data,

		//'ajaxUpdate'=>true,

		'ajaxUpdateError'=>'js:function(){alert("Error");}',

));

		$this->endWidget('zii.widgets.grid.CGridView');

Any idea why this is happening?

tnx

Solved it by adding "$(document).off("click.yiiGridView");" right before the ajax-call in the main view…

Dunno if this is a good fix or not…