CJuiDialog Close Automatically With IFrame In Yii

Cjuidialog Controller [CjuidialogController.php]

I added the controller for cjuidialog action.

<?php
class CjuidialogController extends Controller
{
    public function actionCJuidialog(){
        $this->render("cjuidialog");
    }
    public function actionAjax(){
        $this->render("ajax");
    }
}
?>

CjuiDialog View [cjuidialog.php]

Using this code I added content into iframe via ajax request. I called "cjuidialog/ajax" action to get the content and i load that content into iframe.

<?php
    Yii::app()->clientScript->registerScript("iframe-cjuidialog","
        
        $('#opencjuidialog').live('click',function(){
            $('#iframe').attr('src','".Yii::app()->createAbsoluteUrl("cjuidialog/ajax")."'); 
            $('#cjui-dialog').dialog('open');  
            return false;                        
        });        
    ");
?>
<?php
    $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>'cjui-dialog',
    'options'=>array(
        'title'=>'Ajax Jui Dialog IFrame',
        'autoOpen'=>false,
        'modal'=>true,
        'width'=>200,
        'height'=>200,
        'close'=>'js:function(){                             
        }',
    ),
    ));
?>
    <iframe id="iframe" width="100%" height="100%"></iframe>
<?php 
    $this->endWidget();
    
    echo CHtml::link("Ajax CJuidialog","#",array("id"=>"opencjuidialog"));
?>

CjuiDialog Ajax View With Auto Close [ajax.php]

This content will open into iframe of cjuidialog via ajax. When it loaded, It shows one alert box and then it will close automatically.

<?php
    Yii::app()->clientScript->registerScript("iframe-cjuidialog-ajax","
    alert('CJuidilog will close now');
    window.parent.$('#cjui-dialog').dialog('close');
    window.parent.$('#iframe').attr('src','');        
");
?>
Welcome Yii CJuiDialog