I have a button in a CButtonColumn that fires an ajax request. If the user clicks on it multiple times it generates multiple requests, something I don’t want to happen. I’ve tried disabling the anchor tag in the onclick handler, and in the beforeSend option in the ajax criteria, but without success. The functions fire, but subsequent clicks still fire the ajax request.
Some of the attempts I have tried in the onclick and beforeSend options are:
this.attr("href")="";
this.disabled=true;
js:$(this).attr("disabled")="disabled";
if($(this).attr("disabled") == "disabled") {return false} else {$(this).attr("disabled") = "disabled"}
if (js:$(this).attr("disabled") == "disabled") {return false} else {js:$(this).attr("disabled") = "disabled"}
Does anyone have any ideas?
Here is the code for the CButtonColumn:
'buttons'=>array(
'endPeriod'=>array('imageUrl'=>Yii::app()->request->baseUrl.'/images/calendar_view_day.png',
'url'=>'Yii::app()->createUrl("user/endPeriod", array("id"=>$data->id, "userId"=>$data->user_id ))',
'options'=>array('title'=>'End current period and create new period',
'ajax'=>array('type'=>'get',
'url'=>'js:$(this).attr("href")',
'success' => 'js:function(data) { reloadGrids(data);}'
),
),
),
),
Thanks in advance