如何在 Facebox 弹出窗口仍然打开时加载另一个 div?

发布于 2024-09-16 08:27:50 字数 678 浏览 4 评论 0原文

我刚刚弄清楚如何使用 Facebox。我可以在 Facebox 中打开隐藏的 div,但如何让它转储当前的 div 并加载另一个 div,而不关闭弹出窗口?如果用户单击弹出窗口内的链接,我希望 Facebox 弹出窗口加载另一个 div(同时转储前一个 div)。我已经尝试过这样的事情:

<script type="text/javascript">
        jQuery(document).ready(function($) {
            $('a[rel*=facebox]').facebox({})
        })
</script>

<a href="#div1" rel="facebox">Div1</a>
<div id="div1" style="display:none;">
   <a href="#div2" rel="facebox">Load the other div</a>
</div>
<div id="div2" style="display:none;">
   <p>Other div</p>
</div>

我不知何故知道事情没那么简单。我已经尝试在网上搜索答案,但没有找到答案。这可能吗?对于 Javascript,我完全是个菜鸟,所以请耐心等待。

I just figured out how to use Facebox. I can open hidden divs in Facebox but how do I get it to dump the current div and load another one without closing the pop-up? I want the Facebox pop-up to load another div (while dumping the previous one) if the user clicks on a link inside the pop-up. I already tried something like this:

<script type="text/javascript">
        jQuery(document).ready(function($) {
            $('a[rel*=facebox]').facebox({})
        })
</script>

<a href="#div1" rel="facebox">Div1</a>
<div id="div1" style="display:none;">
   <a href="#div2" rel="facebox">Load the other div</a>
</div>
<div id="div2" style="display:none;">
   <p>Other div</p>
</div>

I somehow knew it wasn't this simple. I already tried searching the net for answers but no dice. Is this even possible? I'm a complete noob when it comes to Javascript so please bear with me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风铃鹿 2024-09-23 08:27:50

我已经找到答案了。显然,您需要将其绑定到鼠标单击事件并执行递归。我是这样做的:

<script type="text/javascript">
    function find_hidden(){
        $('.infinite')
        .unbind('click')
        .bind('click', function() {
            var glink = $(this).attr('href');
            jQuery.facebox({div: glink});
            find_hidden();
        });
    }
</script>

我在此处找到了答案。

I found the answer already. Apparently, you need to bind it to a mouseclick event and perform recursion. Here's how I did it:

<script type="text/javascript">
    function find_hidden(){
        $('.infinite')
        .unbind('click')
        .bind('click', function() {
            var glink = $(this).attr('href');
            jQuery.facebox({div: glink});
            find_hidden();
        });
    }
</script>

I found the answer here.

七月上 2024-09-23 08:27:50

通过浏览源代码,我认为您可以只传递一个字符串,如下所示:

$.facebox('<div>test</div>');

From skimming through the source, I think you can just pass a string, like this:

$.facebox('<div>test</div>');
我不在是我 2024-09-23 08:27:50

试试这个:

jQuery("#facebox_overlay").click();jQuery.facebox({ div: '#your-new-div-id' });

Try this:

jQuery("#facebox_overlay").click();jQuery.facebox({ div: '#your-new-div-id' });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文