简体   繁体   中英

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.

When I press 'login with twitter' button in fancybox dialog, then I want to close the fancybox and redirect to a route(login/twitter)

When I press 'login with facebook' button in fancybox dialog, then I want to close the fancybox and redirect to a route(login/facebook).

To know where to route, I need to know which button is click in the afterClose callback function.

//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?

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 .

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.

Submit a form inside fancybox and redirect the page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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