0

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'

mdietz
  • 33
  • 1
  • 1
  • 6

1 Answers1

0

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;')),
hemc4
  • 1,623
  • 3
  • 18
  • 32
  • Hi, thanks for the reply. It is still operating the same as it was before but with your code, it's now just a different style. Both my original code and your code creates a menu item with the word HELP and when I click on it, it still opens up a dialog box with the title 'Menu Alert' but it's still missing the body of the dialog which I'd like to put some text like 'Available Soon' – mdietz Jul 16 '13 at 13:39
  • I have tested it is displaying var $dialogText text in body, Please check whether var contains value or not. – hemc4 Jul 16 '13 at 15:03
  • Hi Hemc, maybe that's my confusion. Can't I embed the value of the variable in the array as shown in the last parameter of the menu item 'dialogText'=>'Available Soon'? That way if I have have multiple menu items which need popups, I can just add that parameter to each item? – mdietz Jul 16 '13 at 17:09
  • The text 'Available soon' still isn't displaying in the popup body. – mdietz Jul 22 '13 at 14:13
  • I have edited my answer, now it will output exacttly you want – hemc4 Jul 23 '13 at 07:29