Shadowbox - 如何切换或替换内容?如何关闭并打开另一个对话框? [英] Shadowbox - How to switch or replace content? How to close and open another dialog?

查看:117
本文介绍了Shadowbox - 如何切换或替换内容?如何关闭并打开另一个对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在多个场合使用shadowbox:有时我偶然需要多个对话框。

I'm trying to use shadowbox in multiple occasions: sometimes I happen to need more than one dialog at the same time.

在这个简单的例子中,我尝试关闭一个现有窗口并重新打开另一个窗口,但不打开第二个窗口。我在做什么错?

In this simple example I try to close one existing window and re-open another one but is not opening the second one. What I'm doing wrong?

<!DOCTYPE HTML>
<html>
<head>
    <link rel="stylesheet" href="shadowbox.css" type="text/css">
    <style type="text/css" media="screen">
        #sb-body, #sb-loading { background:#eee; }
    </style>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
    <script src="shadowbox.js" type="text/javascript" charset="utf-8"></script>

    <script type="text/javascript">

        Shadowbox.init();

        window.onload = function(){

            Shadowbox.open({
                content: 'First window. <a id="open-second" href="http://www.google.com">open another window</a>.',
                player: "html"
            });

            $('#open-second').live('click', function(e){
                e.preventDefault();

                Shadowbox.close();
                Shadowbox.open({
                    content: 'Second window.',
                    player: "html"
                });
            });
        };
    </script>
</head>
<body>blabla.</body>
</html>

注意,

Adit

Regards,
Adit

推荐答案

对不起,这个,但是我想我会走向彩色框,因为它看起来更加稳定:

Sorry 'bout this, but I think I'll move towards colorbox as it seems far more stable:

$('#second-btn').live('click', function(e){
  e.preventDefault();
  $.colorbox({
    onComplete: function(){
      $('#cboxLoadedContent').append('second opened');
      $('#cboxClose').attr('id', 'cboxClose_disabled');
    },
    html:'<p>Second <a id="first-btn" href="x">first</a></p>',
    width: 500, height: 200
  });
});

function showfirst(){
  $.colorbox({
    onLoad: function(){ $('#cboxClose_disabled').attr('id', 'cboxClose'); },
    onComplete: function(){ $('#cboxLoadedContent').append('first opened') },
    html:'<p>First <a id="second-btn" href="x">second</a></p>',
    width: 500, height: 200
  });
}

$('#first-btn').live('click', function(e){
  e.preventDefault();
  showfirst()
});

showfirst();

嘿,我一个人说话吗? XD

Hey, am I talking alone?! XD

这篇关于Shadowbox - 如何切换或替换内容?如何关闭并打开另一个对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆