简体   繁体   English

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

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

In the parent html page , when I click a link fancybox dialog opens up and I load a laravel php view page in that fancybox. 在父html页面中,当我单击链接时,fancybox对话框打开,并在该fancybox中加载laravel php视图页面。

When I press 'login with twitter' button in fancybox dialog, then I want to close the fancybox and redirect to a route(login/twitter) 当我在fancybox对话框中按“使用Twitter登录”按钮时,我想关闭fancybox并重定向到路由(登录/推特)

When I press 'login with facebook' button in fancybox dialog, then I want to close the fancybox and redirect to a route(login/facebook). 当我在fancybox对话框中按“使用facebook登录”按钮时,我想关闭fancybox并重定向到路由(登录/ facebook)。

To know where to route, I need to know which button is click in the afterClose callback function. 要知道要路由到哪里,我需要知道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
});

How to pass the signupSource from Fancybox.php to parent.php? 如何将signupSource从Fancybox.php传递给parent.php?

Made all the those buttons as submit buttons and based on the value received in the posted var corresponding to it.. i got to kknow the signup source . 将所有这些按钮设置为“提交”按钮,并根据与之对应的已发布var中接收到的值进行设置。

Instead of closing fancy box parent.$.fancybox.close();and using afterClose callback .. i used target='_top' which automatically posted my form data to parent window and also closed the fancybox before posting it. 而不是关闭fancy box parent。$。fancybox.close();并使用afterClose回调..我使用target ='_ top',它自动将表单数据发布到父窗口,并在发布前关闭了fancybox。

Submit a form inside fancybox and redirect the page 在fancybox内提交表单并重定向页面

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

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