CJuiDialog and buttons

The jQuery UI Dialog supports the option ‘buttons’.

So I tried to:

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


    // additional javascript options for the dialog plugin


        '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.

Hm, seems it was discussed already.

‘js:’ should help.

Many thanks :slight_smile: