Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在yii中提交表单时如何关闭fancybox_Php_Jquery_Yii_Fancybox - Fatal编程技术网

Php 在yii中提交表单时如何关闭fancybox

Php 在yii中提交表单时如何关闭fancybox,php,jquery,yii,fancybox,Php,Jquery,Yii,Fancybox,我在yii中使用fancybox作为表单,问题是当我提交表单时,动作被加载到fancy box中,我想要的是关闭fancy box并在正常页面中打开动作,我该如何做这是我的yii代码 呼叫fancybox <?php $this->widget('application.extensions.fancybox.EFancyBox', array( 'target' => 'a#update', 'id' => 'referr

我在yii中使用fancybox作为表单,问题是当我提交表单时,动作被加载到fancy box中,我想要的是关闭fancy box并在正常页面中打开动作,我该如何做这是我的yii代码

呼叫fancybox

<?php
        $this->widget('application.extensions.fancybox.EFancyBox', array(
        'target' => 'a#update',
        'id' => 'referrallink',
        'config' => array(
            'type' => 'iframe',
            'width' => 500,
            'height' => 500,
            'titleShow'=>true,
            'hideOnContentClick'=>true,
            'autoScale'=>true,
        ),));
    ?>

我希望它能帮助您:

使用JS或JQuery,在表单提交之后,您可以关闭Fancybox实例,例如Ajax提交(使用JQuery):

Fancybox回调设置:

    $("#fancyboxElement").fancybox({
        onClosed : function() {
                    location.href = 'my/target/url/after/close';
            }
});
编辑:Yii Fancybox扩展设置示例(旧的Fancybox版本,而不是版本>=2)和:


    public function actionUpdate($id)
{
    $model=$this->loadModel($id);

        // Uncomment the following line if AJAX validation is needed
        $this->performAjaxValidation($model);

        if(isset($_POST['Merchant']))
        {
            $model->attributes=$_POST['Merchant'];
            $dir='images/merchant';
            if($model->save())
            {
                unlink($model->logo);
                $id=$model->id;
                $file=CUploadedFile::getInstance($model,'logo');
                $fname="$dir/$id.{$file->getExtensionName()}";
                $file->saveAs($fname);
                $model->saveAttributes(array('logo'=>$fname));
                //die($model->password);
            $this->redirect(array('view','id'=>$model->id));
            }
        }

        $this->render('update',array(
            'model'=>$model,
        ));
}
    $("#idForm").submit(function(event) {
            event.preventDefault(); // avoid default form submit
            var url = "path/to/your/server/post/script.any";

            $.ajax({
                    type: "POST",
                    url: url,
                    data: $("#idForm").serialize(), // read and prepare all form fields
                    success: function(data) {
                            // trigger fancybox close on same modal window 
                            $.fancybox.close(); 
                            // trigger fancybox close from parent window
                            // parent.$.fancybox.close()
                    }   
            });
    });
    $("#fancyboxElement").fancybox({
        onClosed : function() {
                    location.href = 'my/target/url/after/close';
            }
});
    <?php 
            $config = array(
                    'width' => '100%',
                    'height' => '100%',
                    'autoScale' => true,
                    'scrolling' => 'yes',
                    'transitionIn' => 'none',
                    'transitionOut' => 'none',
                    'type' => 'iframe',
                    'showNavArrows' => false,
                    'enableKeyboardNav' => false,
                    'onStart' => 'js:function(){            
                        window.confirm("Continue?");                 
                    }',
                    'onCancel' => 'js:function(){            
                        alert("Cancel");                 
                    }',
                    'onComplete' => 'js:function(){            
                        alert("Completed!");                 
                    }',
                    'onCleanup' => 'js:function(){            
                        return window.confirm("Close?");                 
                    }',
                    'onClosed' => 'js:function(){            
                        alert("Closed");                 
                    }'
                );

            $this->widget('application.extensions.fancybox.EFancyBox', 
            array( 
               'target' => 'a[rel=selection_list]',
               'config' => $config,
            ));
    ?>