[SOLVED] cgridview ajax call in column

in my admin view file, i have a CGridview with the following column:







        	'value'=>'Master::getIsPresentInLocation($data->ID, '.Yii::app()->session["label_location_id"].');',



the "getIsPresentInLocation" function from the Master model returns the following ajaxButton :


			$str =  TbHtml::ajaxButton(

					'Add '.Yii::app()->session["label_location_id"],

					Yii::app()->createUrl('master/togglePresent', array("id"=>$id, "location_id"=>Yii::app()->session["label_location_id"])),



							$.fn.yiiGridView.update('master-grid', {data: $(this).serialize()});










		return $str;

and the "togglePresent" function in the controller :

	public function actionTogglePresent($id, $location_id){

		$sql ="


			FROM MapPlants mp

			INNER JOIN Location l ON (l.ID = $location_id)

			INNER JOIN LocationMap lm ON (lm.LocationID = l.ID)

			WHERE (mp.MasterID = $id) AND (mp.LocationMapID = lm.ID)


		$command =Yii::app()->db->createCommand($sql);

		$res = $command->queryRow();

		if ($res){

			echo "present";


		else {

			$modelLocationMap = LocationMap::model()->find('LocationID = ?', array($location_id));

			if ($modelLocationMap) {

				$modelMapPlants = new MapPlants;

				$modelMapPlants->LocationMapID = $modelLocationMap->ID;

				$modelMapPlants->MasterID = $id;


				echo "added plant to location";



				echo "error adding plant";




this works when I click the buttons in the grid, but at some point it generates a whole lot of GET calls in the Firebug console and then the "success" function is not called, or, at least, the "console.log(data)" does not appear…

I tried wrapping the grid refresh in a "setTimeout" call as so:

setTimeout('$.fn.yiiGridView.update(\"master-grid\", {data: $(this).serialize()});', 2000);

but although that seems to help somewhat, it did not solve the problem…

someone have an idea of what might be happening here in this flow of events ?

Going through the forums I see that it is a well-known bug with jquery.js being loaded twice, and I presume that I need to prevent it being re-loaded when the grid is being refreshed with the following call


I need to insert the following lines somewhere

    	Yii::app()->clientScript->scriptMap['jquery.js'] = false;

    	Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;

but not sure where…

solved it by using a button with an onclick handler instead of an ajaxButton.