Set CJuidialog title dyanmically

The title can be set in the widget definition, e.g.:


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

	'id'=>'mymodal',

	'options'=>array(

    	'title'=>'send message to this firm',

....

But I want to pass the PHP variable $name variable to title, so that every time the title of dialog will be like "send message to company XYZ".

I am trying to put <?php $name ?> there, but it is within quote mark and won’t work. Please help!

Thank you!

  • Nick

...

    'title'=>$name,

...

I am sorry. Maybe I didn’t explain the situation clearly.

You can use


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

        'id'=>'mymodal',

        'options'=>array(

        'title'=>$name,

....

To initiate the widget, but what I want to do is to change the ‘title’ every time the dialog is opened, because it’s open at different place to send message to different companies.

How can change the title here?


            	<?php echo CHtml::Button('Join',                    	

                    	array('onClick'=>'$("#mymodal").dialog("open");'),

                    	array('id'=>$data['id'],

                        	'companyName'=>$data['name'])

                    	); ?>

I dont undertand what do ou need because this is the way:




        'title'=>$name,



And you just need to change $name value to change title every time.


 'title'=>$name,

can only be used in widget definition in view page, right?

I use a CListView to output a button in each row item( to send message to the company in that row). The button is used to call out the CJuidialog that is pre-defined by this code:


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

        'id'=>'mymodal',

        'options'=>array(

        'title'=>$name,

....

So how can I changed the dialog title for that company in its row? please refer to the picture.

Thank you very much for replying to me again!

ok, your problem are not in the creation, your problem are in the call of hte dialog, as i say in jquery UI webpage, the form for change dynamically the value of a dialog is using the setter, as in the help this is how you should write your code




 <?php echo CHtml::Button('Join',                        

                        array('onClick'=>'$("#mymodal").dialog("option","title"=>"New title");$("#mymodal").dialog("open");'),

                        array('id'=>$data['id'],

                                'companyName'=>$data['name'])

                        ); ?>




i try this code with a dialog loaded using ajax and it works

Hiya All.

I found this code didn’t work so i found the following works




$("#mymodal").dialog("option","title", "New Title");



Regards