Creating A Cjuidialog With Disabled Buttons

So this is an example I copied from YiiPlayground showing how to use a dialog with callback. Would there be an easy way to modify this so that "select" is disabled until a field in the dialog is filled in?


<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(

       'id'=>'findClient',

        'options'=>array(

            'title'=>'Find Client',

            'autoOpen'=>false,

            'modal'=>true,

            'buttons'=>array(

                'Select'=>'js:addItem',

                'Cancel'=>'js:function(){ $(this).dialog("close");}',

            ),

        ),

)); ?>

Add this line to the options:




'open'=>"js:function () {

          $(this).siblings('.ui-dialog-buttonpane').find('button').button('disable');

        }"



You can replace the siblings and find selectors with whatever you find the easiest to select the buttons you want disabled in the dialog.

Once you determine the field is filled call the same selector with .button(‘enable’) to re-enable the button.

It should be noted, also, that this function will be called whenever the dialog is opened, so you may wish to add a check to see if the field is already filled when the dialog is opened before disabling the button.