How to create a menu item with a dynamic dialog message in yii

532 Views Asked by At

I was looking to put a dynamic popup dialog in a yii menu but am missing a trick to make it dynamic. (edited: or maybe the question should be 'How can I pass a widget some text through a variable from a menu array) As per the code below:

/*Create A Popup Dialog (Gets called from menu)*/
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
    'id'=>'mydialog',
    'options'=>array(
        'title'=>'Menu Alert',
        'autoOpen'=>false,
    ),
));

    echo $dialogText; //Dynamic rather than just static text

$this->endWidget('zii.widgets.jui.CJuiDialog');
/* End of Popup Menu*/
//------------------------------------------------
$this->menu=array(
    array('label'=>'Help', 'url'=>array('xyz'),'linkOptions' => array('onclick' => '$("#mydialog").dialog("open"); return false;','dialogText'=>'Available Soon')),
);

When I use this code, a dialog box appears without the dialog message 'Available Soon'

1

There are 1 best solutions below

5
On

Use text instead of dialogText and place it before dialog open

 array('label'=>'Help', 'url'=>array('xyz'),'linkOptions' => array('onclick' => '$("#mydialog").text("Available soon"); $("#mydialog").dialog("open"); return false;')),