Javascript UI对话框未首次打开

时间:2014-06-29 15:09:20

标签: javascript jquery dialog

我正在尝试使用jQuery UI对话框。但它不会第一次打开。考虑:

<html>
   <head>
      <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css" />
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> 
      <script src="dialog.js"></script>
   </head>
   <body>
      <p>Hello</p>
      <div id="dialog" title="Alert" style="display: none;"></div>
   </body>
</html>

其中dialog.js是:

$(document).ready(function(){
    showAlert("1");
    showAlert("2");
});

function showAlert(str) {
    $( "#dialog" ).html(str);
    $( "#dialog" ).dialog({
        modal: true,
        title: "Alert",
        buttons: {
            "OK": function() {
                document.getElementById("submit").value="Submit";
                $( this ).dialog( "close" );
            }
        }
    });
}

这只会显示第二个对话框,第一个对话框(带有文字&#34; 1&#34;)似乎只是被忽略了..

另见jQuery UI Dialog - Won't open the first time

0 个答案:

没有答案