Double Clicking On Grid View Row Gives Unpredictable Results

I’m not sure if this is a feature or a bug. For most of my admin views, I have code like this:


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'deposit-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'id',

		'club_id',

		'deposit_date',

		array(

			'class'=>'CButtonColumn',

		),

	),

	'selectionChanged'=>"function(id){window.location='" . Yii::app()->urlManager->createUrl('deposit') . "/' + $.fn.yiiGridView.getSelection(id);}",

)); ?>



With this setup, when I click on the grid view row, I get the view of that model.

However, I noticed yesterday, that if I double click on the row, sometimes I get the model view and sometimes I get the index view. It seems like in my development environment I get the model, but on the server I get the index view. It looks to me like maybe the double click is creating two calls. On the first click it retrieves the id okay and gives me the model view, but then it processes the second click. By that time, the page has changed enough that it can’t retrieve the id, so it gives me the index view, which is basically the model view but without an id.

Anyone else run into this? Is it supposed to work like this? Any obvious work around that I am missing?

I have done something like this:




					'afterAjaxUpdate'=>'function(id, data){

						var gridTable = $(data).find("div#bicycle-grid>table");

						$("div#bicycle-grid>table>tbody>tr").bind("dblclick", function()

						{

							dblClickRow($(this));

						});

						}',




and made the function like this:




<script>

	$(document).ready(function()

	{

		$('#bicycle-grid>table>tbody>tr').dblclick(function()

		{

			dblClickRow($(this));

		});


	})

	function dblClickRow(theRow)

	{

		var theUrl = $(theRow).find('a.update').attr('href');

		window.location=theUrl;

	}

</script>



This worked for me, hope it will work for you as well.