Hi everyone,
I am new to Yii framework and want a simple help.
I want to disable the ajaxButton() beforeSend and enable it back on complete (or success). I got it to work with the following code:
<?php
echo CHtml::ajaxButton(
'Submit',
array('controlleraction'),
array(
'success' => 'js:
function (data){
alert(data);
$("#yt0").attr("disabled","");
}
',
'type' => 'POST',
'beforeSend' => 'js:
function(){
$("#yt0").attr("disabled","disabled");
}
',
));
?>
However, I got the selector "yt0" by inspecting with Firebug. Is there a tidier way to do it? Or at least a better way to get the selector id? Any help/comments will be appreciated.
UPDATE: I want to clarify that the controlleraction is a long running resource intensive task and I don’t want the user to click the button multiple times.