jQuery colorbox插件将值从iFrame传递到父onCleanup事件

jQuery colorbox插件将值从iFrame传递到父onCleanup事件,jquery,colorbox,Jquery,Colorbox,在家长方面,我有: $.colorbox({width:"400px", height:"400px", iframe:true, href:"test.html"}); 因此,在我的iFrame中,我尝试了: $(document).ready(function() { window.parent.$.bind("cbox_cleanup", function() { alert("test"); }); }); 这一切都是为了在用户通过单击色框边界外的动作

在家长方面,我有:

$.colorbox({width:"400px", height:"400px", iframe:true, href:"test.html"});
因此,在我的iFrame中,我尝试了:

$(document).ready(function() {
    window.parent.$.bind("cbox_cleanup", function() {
        alert("test");
    });
});
这一切都是为了在用户通过单击色框边界外的动作关闭色框时,将在iFrame中设置的值传递给父对象。尽管我没有得到任何错误,但上面的代码并没有触发


非常感谢您的帮助或建议。

在colorbox选项中设置您的活动

$.colorbox({
    width:"400px",
    height:"400px",
    iframe:true,
    href:"test.html",
    onCleanup: function() {
        alert('test');
    }
});

只需一个信息,一旦启动关闭过程,onCleanup就会触发。

请尝试仅使用父项。$.bind。。。。尽管如此,由于您拥有该页面,我认为您可以从cbox_清理中深入到iFrame并获取值。如果您不拥有该页面,则由于用户界面/用户体验方面的原因,您不希望使用框架进行访问。谢谢您的回复。我试过了,但还是不走运。我尝试从iFrame中绑定事件钩子而不是使用来自父级的回调的原因是,用户正在iFrame中设置一个我想要传递回父级的值。我可以使用回调并尝试使用jQuery data方法将用户值附加到iFrame,我猜……结果证明这是可行的:parent.$parent.document.bindcbox_cleanup,函数{//do somethine here};虽然它只是第一次起作用。连续打开颜色框会导致父项未定义,所以我猜我需要在某个地方解除绑定!