在 fancybox 中单击按钮时将参数传递给 afterclose 回调

Pass arguments to afterclose callback on click of button in fancybox

在父 html 页面中,当我单击 link fancybox 对话框时,我会在该 fancybox 中加载 laravel php 查看页面。

当我在 fancybox 对话框中按下 'login with twitter' 按钮时,我想关闭 fancybox 并重定向到路由 (login/twitter)

当我在 fancybox 对话框中按下 'login with facebook' 按钮时,我想关闭 fancybox 并重定向到路由(login/facebook)。

要知道路由到哪里,我需要知道在 afterClose 回调函数中单击了哪个按钮。

//parent.php

$(".myDiag").fancybox({
        width       : 900,
        height      : 600,
        maxWidth    :"95%",
        padding     : 0,
        fitToView   : false,
        autoSize    : true,
        autoScale   : true,
        autoDimensions: true,
        closeClick  : false,
        openEffect  : 'none',
        closeEffect : 'none',
        afterClose : function(signupSource)
            {
                if(signupSource)
                {
                    window.location = "<?php echo route('login'); ?>" + "/" + signupSource;
                }   
            }
    });

//js in Fancybox.php


$('#loginWithTwitter').click(funciton(){
    parent.$.fancybox.close('twitter');  // 'twitter' is not getting sent to the afterClose callback function
});

如何将 signupSource 从 Fancybox.php 传递到 parent.php?

将所有这些按钮设为提交按钮,并根据相应的已发布 var 中收到的值..我知道了注册源。

而不是关闭花哨的框 parent.$.fancybox.close(); 并使用 afterClose 回调..我使用 target='_top' 自动将我的表单数据发布到父 window 并且发布前关闭 fancybox。

Submit a form inside fancybox and redirect the page