1

我之前在这个论坛上的 qstn 是关于动态地将文本分配给 jquery 中的按钮,我在这里得到了解决方案。现在我的问题是,单击该按钮后,我必须打开另一个带有 2 个按钮的 UI 对话框。我已经编写了以下代码。我能够打开 UI 对话框,但没有出现按钮。请帮助我更改我的代码。

<html>
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    </head>
    <body>
        <div id="selector" title="Pop Up" class = "selector"> <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span> Do u want to save the score?</p> </div>
        <script>
        var monthNames = ["January", "February", "March", "April", "May", "June",                    "July", "August", "September", "October", "November", "December"];
        var today = new Date();
        var month = monthNames[today.getMonth()];
        var nextMonth = monthNames[today.getMonth() + 1];

        $(".selector").dialog({buttons: [
                {
                    text: month,
                    click: function() {
                     $("#opener").dialog({modal: true, height: 590, width: 1005 });
                        $(this).dialog("close");
                    }
                },
                {
                    text: nextMonth,
                    click: function() {
                        $(this).dialog('close');
                    }
                }
            ]});

        </script>
        <script>

          $(".opener").dialog({buttons: [
                {
                    text: "ok",
                    click: function() {
                        $(this).dialog("open");
                    }
                },
                {
                    text: "cancel",
                    click: function() {
                        $(this).dialog('open');
                    }
                }
            ]});

    </script>

    <div id="opener" title="Pop Up" class = "opener" width ="100px"> 
    <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
    Score will be updated</p> </div>


</body>

4

1 回答 1

3

好吧,您还没有指定要在这行代码中显示的任何按钮:

$("#opener").dialog({modal: true, height: 590, width: 1005 });

也许你想这样 intiliazie 它,而不打开:

  // did you mean to select #opener or .opener??
  $("#opener").dialog({buttons: [
        {
            text: "ok",
            click: function() {
                $(this).dialog("open");
            }
        },
        {
            text: "cancel",
            click: function() {
                $(this).dialog('open');
            }
        },
        autoOpen: false
    ]});

然后在另一个对话框的另一行中打开它,如下所示:

$("#opener").dialog('open');
于 2013-08-13T06:09:35.517 回答