ajaxButton() disable 'beforeSend' and enable back on 'complete'

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:


            echo CHtml::ajaxButton(




                        'success' => 'js:

                                    function (data){





                        'type' => 'POST',

                        'beforeSend' => 'js:







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.

to get the clicked object use jquery ajax option context