How can I render a view as a popup?

I want to display a view in another browser window.

I need to pass the $model.

Would I use render in the controller?

Not sure of the syntax.

Thanks

Don’t really understand your question as rendering is done through controller/action.

Maybe you need to set the location of that browser window to that of the controller/action you wish to render?

I wnat to have a link in the list that when a user clicks on it I popup a windows for printing the contents that is retrived from the database.

I need to pass the id or $model to the popup so I can display the database fields.

I did this in codeigniter, but they had an easy function called anchor_popup.

Not sure how to do this in yii.

You could use a jQuery dialog. That would be neater IMO.

It will work even if people have a popup-blocker, which I suspect the majority has turned on nowadays.

CJuiDialog is one possible way:

cjuidialog-and-ajaxsubmitbutton/

Thanks, that looks complicated to me.

I need to digest this.

Are there aby simple examples?

There are tons of ways to do it, I do prettyPhoto or lightboxes and play with classes and set the plugins on the onready functions but…

Lets do it veeery simple:

on the view that you display the link that opens the window, htmlOptions:

‘onclick’=>‘javascript: window.open("’.$this->createUrl(‘controller/action’).’");’

develop from there (Jquery dialogs, lightbox, etc)

Hope it helps

Thanks Antonio, I give that a try and work on it.

Where can I find more info on using jQuery to do this?

Regards,

Frank

You can try out fancybox jQuery plugin.

www.fancybox.net

Add this code in your main layout file:




Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/jquery.fancybox-1.3.1.css');

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/fancybox/jquery.fancybox-1.3.1.pack.js', CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScript('fancyboxClick', '$("a[rel=fancybox]").fancybox();', CClientScript::POS_READY);

Of couse you need to download fancybox archive and extract it into proper location.

Then you just need to change rel property of url to be "fancybox"


<a href="some_link.html" rel="fancybox">here we go</a>

+you need to modify controller action which handle access to "some_link.html" and change layout to false.

enjoy :)

I am. Thanks a lot. :D

anyone tried this with CGridView ? (a lot of links)

I have used this proposed solution.

Thanks for this tip and solution

There is also the extension:

http://www.yiiframework.com/extension/fancybox/

diggy please can you explain in detail … because i tried what you said but i am going wrong somewhere … can you please send a full example … thanks a lot …

http://www.yiiframework.com/forum/index.php/topic/49527-update-content-with-ajax-and-ajax-auto-refresh-div/page__view__findpost__p__230887

you can use this may help full…

‘link’=>array(

                    'header'=&gt;'Go to...',


                    'type'=&gt;'raw',


               	    'value'=&gt; 'CHtml::button(&quot;button label&quot;,array(&quot;onclick&quot;=&gt;&quot;document.location.href=&#092;'&quot;.Yii::app()-&gt;controller-&gt;createUrl(&quot;Cities/create&quot;,array(&quot;city_id&quot;=&gt;&#036;data-&gt;city_id)).&quot;&#092;'&quot;))',

i added in my admin page this button will come in gridview…

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=&gt;'cities-grid',


'dataProvider'=&gt;&#036;model-&gt;search(),


'filter'=&gt;&#036;model,


'columns'=&gt;array(


	'city_id',


	'city_name',


	'Discription',


	'city_laitute',


	'city_lontute',


	'pic',


	/*


	'more',


	*/


	'link'=&gt;array(


                    'header'=&gt;'Go to...',


                    'type'=&gt;'raw',


               	    'value'=&gt; 'CHtml::button(&quot;button label&quot;,array(&quot;onclick&quot;=&gt;&quot;document.location.href=&#092;'&quot;.Yii::app()-&gt;controller-&gt;createUrl(&quot;Cities/create&quot;,array(&quot;city_id&quot;=&gt;&#036;data-&gt;city_id)).&quot;&#092;'&quot;))',

// ‘javascript: window.open("’.$this->createUrl(‘controller/action’).’"));’,

// ‘value’=>‘CHtml::button(“button label”,array(“onclick”=>“window.open(”’.$this->createUrl(‘cities/create’).’")));’,

			),                           


                                      


	array(


		'class'=&gt;'CButtonColumn',


	),


),

)); ?>