关闭后无法重新打开对话框


Unable to reopen dialog box after closing

这是我的问题...

我有以下jQuery UI脚本:

    <script>
$(function() {
    $( "#dialog" ).dialog({
        autoOpen: false,
        show: "slideUp",
        hide: "slideDown",
        height: "300",
        width: "400",
        title: "Test pop-up",
        buttons: {
            "Close": function(){
                $(this).dialog("close");
                    }
                }
            }           
        );
    $( "p.diag").click(function(e) {
        var monUrl = 'test2.php'; 
        $('#dialog').load(monUrl, function(response, status) {
        $('#test_dialog').html(response);
    });
    e.preventDefault();
});
    $( "p.diag").click(function() {
    $( "#dialog" ).dialog("open");
    });

这是一个非常简单的代码,当我单击 p.diag 类时,它会正确打开我的对话框,但在我关闭它后它不会打开。

test2.php 页面只需打印一个带有回声"lol"的"lol";

这是我的 HTML :

<div style="height: 200px; min-height: 109px; width: auto;" class="ui-dialog-content  ui-widget-content" id="dialog">
  </div>

谢谢!

请求删除e.preventDefault();

观看此演示:http://jsfiddle.net/ngwJ3/

原因:http://api.jquery.com/event.preventDefault/:如果调用此方法,则不会触发事件的默认操作。

希望这对:)有所帮助