CJuiDialog没有关闭Ajax的成功

时间:2013-12-20 12:09:14

标签: yii

我试图在Ajax成功中关闭CJuiDialog,但它没有关闭,只有iframe内容被清除弹出窗口没有关闭,

CJuiDialog编码:

<?php
$this->beginWidget('zii.Widgets.jui.CJuiDialog',array(
'id'=>'Document-Edit',
'options'=>array(
    'title'=>'Manage Documents',
    'autoOpen'=>false,
    'modal'=>true,
    'width'=>800,
    'height'=>600,
//  'close'=>'js:function(e,o){location.reload();}' ,
),
));
?>
<iframe id="cru-frame-doc" width="100%" height="100%" frameBorder="0" scrolling="no" > 
<?php $this->renderPartial('ManageDocuments_Update', array('model'=>$model)); ?>
</iframe>


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

CGridView代码:

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'document-grid',
    'dataProvider'=>$model->search(),
    'columns'=>array(
    array(
                         'class' => 'CButtonColumn',
                         'template' => '{DocumentEdit}',
                         'buttons' => array(

                             'DocumentEdit' => array(
                             'imageUrl'=>Yii::app()->request->baseUrl.'/images/update.png',
                                    'url'=>'$this->grid->controller->createUrl("DocumentEdit", array("id"=>$data->crm_document_id,"asDialog"=>1))',

                                   'click'=>'function(){

                                    $("#cru-frame-doc").attr("src",$(this).attr("href"));  $("#Document-Edit").dialog("open");  return false;}',

                            ),
                     ),),
       'crm_document_id',
        'name',
        'doc_type',
        'delivery_method',
        'content_subject',
        'content_body',
        'is_active',

    ),

)); ?>

Ajax提交按钮代码:

<?php 
     echo CHtml::ajaxSubmitButton( 'Save',
    'js:document.location.href='.'"'.Yii::app()->createUrl("baseContact/SaveManageDocuments_Update",array("id" => $model->crm_document_id)).'"',  
    array( 
   'type'=>'POST',
    "dataType" => "json",

    'success' =>  'function(data){

      if(data.result=="success"){
    window.parent.$("#Document-Edit").dialog("close");
    window.parent.$("#cru-frame-doc").attr("src",""); 

        }
   }',

    ));
     ?>

任何人都可以指出我犯错误的地方......

1 个答案:

答案 0 :(得分:0)

在SaveManageDocuments_Update Controller操作中使用以下代码关闭对话框

echo CHtml::script("window.parent.$('#Document-Edit').dialog('close');window.parent.$('#cru-frame-doc').attr('src',''); window.parent.$.fn.yiiGridView.update('document-grid');");
                Yii::app()->end();