The jQuery UI Dialog supports the option ‘buttons’.
So I tried to:
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog',
// additional javascript options for the dialog plugin
'options'=>array(
'title'=>'Dialog box 1',
...
'buttons'=>array('Close'=>'function() {$(this).dialog("close");}'),
),
));
The problem is the generation of the options
$options=empty($this->options) ? '' : CJavaScript::encode($this->options);
because this will add js-code like below:
jQuery('#yw3').dialog({'width':800,'height':800,'buttons':{'Close':'function() {$(this).dialog(\"close\");}'}});
But the value of the ‘Close’ key should not be a string:
'Close': function() {$(this)...}
I think I can solve this by adding an extra js-script
$( ".selector" ).dialog( "option", "buttons", { "Ok": function() { $(this).dialog("close"); } } );
but maybe the function CJavaScript::encode should not output function() terms as a string.