繁体   English   中英

在iframe中关闭颜色框

[英]Closing colorbox within iframe

用户尝试执行以下操作后,我尝试打开一个颜色框:

$.colorbox({
    'iframe': true,
    'width':'550px',
    'height':'200px', 
    'href': 'index.html', 
    'onClosed': function()
    { 
        var form$ = $('#book-form');
        form$.get(0).submit();
    }
});

并且我尝试通过执行以下操作(当人们点击“是”链接时)在iframe中将其关闭:

$('#yes').click(function() 
{ 
    parent.$('#repeat_provider').val(" . $booking['provider_id'] . ");

    parent.$.colorbox.close();

    return true;
}); 

但颜色框实际上并未关闭。 不确定我做错了什么?

您所拥有的应该可以工作,但是需要牢记一些注意事项。

如果将此click事件绑定到锚元素,则需要处理默认行为。 而且,如果您在父文档中将$别名与jQuery分开,则需要记住使用jQuery。

$('#yes').click(function() 
{ 
    parent.jQuery('#repeat_provider').val("whatever");
    parent.jQuery.colorbox.close();
    return false; // cancel the default click event
}); 

暂无
暂无

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

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