jquery - 当 fancybox 窗口关闭时将变量传递回父级

标签 jquery variables fancybox parent

我想知道一旦子项关闭,是否可以将变量从 fancybox 子项传递回父项?

function cleanUp(){
    var bla = $("#fancybox-frame").contents().find('input[name=pd_id]');
    alert(bla.val());
}
$("#tree .product a[class!=copy]").fancybox({
    'width'             : 770,
    'height'            : '95%',
    'autoScale'         : false,
    'transitionIn'      : 'none',
    'transitionOut'     : 'none',
    'type'              : 'iframe',
    'onCleanup'         : cleanUp
}); 

最佳答案

在父级中,我定义

var $_returnvalue = false;

onClosed 看起来像这样:

onClosed: function() {
    if ($_returnvalue != false)
    {
        // Do something in the parent
    }

在 fancybox 页面中,当准备好返回某些内容时,我将该值设置为 parent.$_returnvalue,然后关闭该框。这对于从列表中选择某些内容并将该值传递回调用页面非常有效。

关于jquery - 当 fancybox 窗口关闭时将变量传递回父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4590940/

相关文章:

html - 来自与 youtube 不同的来源的视频进入花式盒

jquery - Fancybox - 使用 Iframe 内容更新 fancybox 的大小?

javascript - 每次调整大小时都会加载图像吗?

javascript - 用JS创建带有onMouseOver效果的DIV

javascript - 如何从动态生成的 html 中捕获属性 id?

php - laravel 4 中的全局变量

bash - 如何从 Bash 中的字符串中删除换行符

javascript - 在php中通过jquery AJAX填充数组

javascript - 为什么 JavaScript 变量在一些网站上打印正确,但在其他网站上被认为是未定义的?

jquery - 提交登录表单后关闭 Fancybox 模式窗口并重新加载页面