Pop Up Ajax Render

Hi

I want to make a popup dialogbox like Gii does.

For example in Gii after of preview links appears with the files that are going to be generated.

If someone click one of this links a dialog displayed with code of controller or model etc.

I want the same functional in my controller/action

I found a solution by extension

http://www.yiiframework.com/forum/index.php/topic/13566-how-can-i-render-a-view-as-a-popup

But I want to do that only with jquery and kernel Yii API.

How to do that?

Thanks

need ajax crud ?

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

Hi Rajith R and thanks for your response!

But as I said I try to avoid to use extension for many and small functionality (I want to use an already Yii kernel one)

Hi KonApaz

I tried your idea before by fancybox ext , it’s so easy and not complected .

Read my problem and solutions :

http://www.yiiframework.com/forum/index.php/topic/38740-load-view-with-fancybox/page__p__186260__fromsearch__1#entry186260

Hi samilo

as I said again I try to restrict the using of extensions! I have already huge amount of extension in my project. I think to reduce the extensions that I already use, not increasing! ::)

Anyway, I just wrote I wiki about this and it works! :)

http://www.yiiframework.com/wiki/518/popup-ajax-dialogbox-without-any-extension

Thanks a lot Rajith R and samilo :)

wow thats great KonApaz :) :)

Hi

if is it better way

first you can create the CHTML::ajaxlink


  <?php

        // ================================================= start  

        echo CHtml::ajaxlink('Request New Liquor', array('liquor/addnewliquor'), array(

            "type" => "GET",

            "data" => array("vid" => $vid, "ajax" => true),

            "success" => "function(data){

                                        $.fancybox({content:data,closeBtn:false,showNavArrows:false});

				 }",

                ), array('live' => false, 'class' => 'blue', 'id' => rand(0, 99999)));


        // ================================================= end 

        ?>

Then after call a controller action


public function actionaddnewliquor() {


		$model = new VenueLiquor();

		$this->renderPartial('/liquor/add_new_liquor', array('model' => $model), false, true);

	}

Note:please make sure in renderPartial pass a processoutout. so it’s work in yii validation otherwise create the custom validation using jquery

Hi Ankit

It works fine, bravo!

For less coding, and if someone wants less custom schema of popup he could use the code

http://www.yiiframework.com/wiki/518/popup-ajax-dialogbox-without-any-extension

and replace


echo CHtml::beginForm();

echo CHtml::link('an ajax test', array('controllerA/textA'), array('class' => 'class-link'));

echo CHtml::endForm();

with something like that


echo CHtml::ajaxlink('Request New Liquor', array('liquor/addnewliquor'), array(

            "type" => "GET",

            "data" => array("vid" => $vid, "ajax" => true),

            "success" => "function(data){

                                        $.fancybox({content:data,closeBtn:false,showNavArrows:false});

                                 }",

                ), array('live' => false, 'class' => 'blue', 'id' => rand(0, 99999)));



Also, In this case the file popup.js and


$cs->registerScriptFile(Yii::app()->request->baseUrl . '/js/popup.js');

Is not required

Thanks Rajith :)

Hi KonApaz ,

if you can not include pop.js and fancybox not open so otherwise u can use include on view file may be but i am not sure


$this->widget('application.extensions.fancybox.EFancyBox', array(

    'target'=>'a[rel=gallery]',

    'config'=>array(),

    )

);

Ankit,

I dont check this extension but I think that is an alternative wat to do that!

The extension could achieve the same thing that I wrote in the wiki :)

Hi

ok not an issue and also your extension post it’s nice. it may be helpful.

Thanks KonApaz

I try to reduce the number of extensions in any project as it is possible,

Also, after of user request, I post a comment for my wiki that tell us how to use it

with links in a CGridview

Thanks a lot the Yii community which support me :)