繁体   English   中英

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

[英]Pass arguments to afterclose callback on click of button in fancybox

在父html页面中,当我单击链接时,fancybox对话框打开,并在该fancybox中加载laravel php视图页面。

当我在fancybox对话框中按“使用Twitter登录”按钮时,我想关闭fancybox并重定向到路由(登录/推特)

当我在fancybox对话框中按“使用facebook登录”按钮时,我想关闭fancybox并重定向到路由(登录/ 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中接收到的值进行设置。

而不是关闭fancy box parent。$。fancybox.close();并使用afterClose回调..我使用target ='_ top',它自动将表单数据发布到父窗口,并在发布前关闭了fancybox。

在fancybox内提交表单并重定向页面

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM