How to render view in a dialog?

Hi, this might be an easy problem but I have been staring at it for some time.

I’m trying to render view in a dialog when a button is clicked. I’ve been looking at this guide and tried to modify the code for my purpose but with no luck. I think the problem is the script but I’m not very good at javascript.



	 * Displays a particular model.

	 * @param integer $id the ID of the model to be displayed


	public function actionView($id)


		if (Yii::app()->request->isAjaxRequest)


            echo CJSON::encode(array( 











And the index









					'click'=>'function(){viewProject(); $("#dialogProject").dialog("open");}',





)); ?>


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









)); ?>

<div class="divForView"></div>


<?php $this->endWidget();?>

<script type="text/javascript">

function viewProject()


	<?php echo CHtml::ajax(array(

			//'url'=>'Yii::app()->createUrl("projects/view", array("id"=>$data->Id))',


			'data'=> "js:$(this).serialize()",




				$('#dialogProject div.divForView').html(data.div);

			} ",


	return false; 





Any help would be appreciated.


One obvious problem is that you forgot to add the third parameter (true) to the renderPartial() call.


That I did, thank you for pointing that out.

However it still doesn’t work :)

I just found this discussion hopes this helps