【问题标题】:Pass arguments to afterclose callback on click of button in fancybox单击fancybox中的按钮将参数传递给afterclose回调
【发布时间】:2015-07-27 14:05:42
【问题描述】:

在父 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
});

如何将 Fancybox.php 中的 signupSource 传递给 parent.php?

【问题讨论】:

    标签: javascript jquery html laravel fancybox-2


    【解决方案1】:

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

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

    Submit a form inside fancybox and redirect the page

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-04
      • 2017-02-10
      • 2021-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多