Reputation: 899
I would like to open a dialogbox , but it should be like a part of my menu. I got a CMenu like this:
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Login', 'url'=>"#", 'onclick'=>'$("#mydialog").dialog("open"); return false;'),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'About Me', 'url'=>array('/site/index'),
'items'=>array(
array('label'=>'CV', 'url'=>array('/site/cv')),
array('label'=>'Contact', 'url'=>array('/site/contact')))),
array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
array('label'=>'Register', 'url'=>array('/tblUsers/create'))
),
)); ?>
as u can see i already tried to add it somehow to my menu but i have no idea what i am doing. I can open it outside like this :
echo CHtml::link('open dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;'));
So this is what i actually try to implement in the menu above, with no success.
Upvotes: 1
Views: 1945
Reputation: 3198
You should use linkOptions
or itemOptions
for this purpose:
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Login', 'url'=>"#", 'linkOptions' => array(
'onclick'=>'$("#mydialog").dialog("open"); return false;'),
)),
/* other menu items */
)
)); ?>
Upvotes: 4