Cjuidialog: Render Complete Model View In Dialog

Hello

I want to render view.php (view of model) completely in CJuiDialog as a pop up.

(Not the Form) So many posts on this forum are about render form in the CJuiDialog. I didn’t get any post regarding how to render model view into CJuiDialog

I did some work that display the view into the dialog box,

Problem is, in index.php i have pagination to display 10 records per each page.

after going to next page views of all records render on the index page.


public function actionIndex()

	{     $dataProvider=new CActiveDataProvider('Jobs',array(

					/*'pagination'=>array(

					'pageSize'=>8,

					),*/));

		$this->render('guestview',array(

			'dataProvider'=>$dataProvider,

		));

	}







<?php 

$target = 'window.location='."'".$this->createUrl('jobs/index')."'";

$dialogId = "dialog_{$data->job_id}";

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

		'id'=>$dialogId,

		// additional javascript options for the dialog plugin

		'options'=>array(

			'title'=>$data->job_title,

			'autoOpen'=>false,

			'show'=>array(

                'effect'=>'blind',

                'duration'=>1000,

			),

			'hide'=>array(

                'effect'=>'explode',

                'duration'=>500,

			),

			'buttons' => array(

				array('text'=>'Route','click'=> 'js:function(){'.$target.'}'),

				array('text'=>'Cancel','click'=> 'js:function(){$(this).dialog("close");}'),

			),

			'height'=>500,

			'width'=>450,

			'show'=>'fade',

			'hide'=>'fade',

		),

  ));

  

  //define the model

  //$model=new Jobs;

  

 echo CHtml::link(CHtml::encode(view),array('jobs/view','id'=> $data->job_id));

 

 $this->renderPartial('/jobs/view',array('model'=>$data));

 

  $this->endWidget('zii.widgets.jui.CJuiDialog');

  

  

  ?>

<div class="ca-item-main">

				<img class="ca-images" src="<?php echo Yii::app()->baseUrl."/images/".$data->job_photo?>"  label="<?php $data->job_photo?>"/>

					<h4>

						<!--<span class="ca-quote">&ldquo;</span>-->

						<span><?php  echo CHtml::Link(CHtml::encode('Job-'.$data->job_id), '#', array('jobs/view','onclick'=>'$("#'. $dialogId .'").dialog("open"); return false;',));

						

						 					

						?>

							<?php //echo substr($data->job_desc,0,200)." ...."; ?>

						</span>

					</h4>

			</div>




Hello beingyii,

There few things you must know before proceeding forward,

since when rendering using CJui Dialog javascript conflicts occurrs.

to avoid it first in the view form you’re poping up the dialog

add this script


 "$cs = Yii::app()->clientScript;

  $cs->registerCoreScript('yiiactiveform');"

in the controller action of your dialog popup

set a layout (‘plain one’)


"/* setting plain layout */

        $this->layout = '//layouts/column4';"

before rendering


        /* preventing duplicating the script files this must for jquery dialog */

        Yii::app()->clientScript->corePackages = array();

        Yii::app()->clientScript->scriptMap['jquery-ui.min.js'] = false;

Note - if you’re using render partial if any widgets in the form those scripts wont be included to the form I’m using render to avoid it plus with renderPartial return -false, processOutput - true


$this->renderPartial('_form-popup', array('model' => $model), false, true);

my column 4 layout


<?php Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl . "/css/bootstrap_extended.css"); ?>

<div class="container-fluid">

    <div class="row">

        <div id="col-sm-9 col-lg-6">

            <?php echo $content; ?>

        </div><!-- content -->

    </div> 

</div> <!-- page-->

Note - Main form ajaxLinks must be uniquly identified same as the popup from ajax buttons


 <?php

                echo CHtml::ajaxLink(Yii::app()->params['addANewRecord'], Yii::app()->createAbsoluteUrl('StItemMainCat/AjaxCreate'), array('update' => '#mainCatDialog'), array('id' => 'mainCatAjaxLink' . uniqid(), 'onclick' => '$("#mainCatDialog").dialog("open")'));


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

                    'id' => 'mainCatDialog',

                    'options' => Common::getDialogOptions(array('title' => 'Create New Main Category')),

                ));

                $this->endWidget('zii.widgets.jui.CJuiDialog');

                ?>