对话框第一次关闭,但第二次不关闭



我有一个对话框,第一次工作时很好,即当我单击其中的编辑按钮时,它会很好地关闭。但第二次,当我点击编辑按钮时,它就不起作用了。

$(document).ready(function() {
    $('.btn').click(function() {
        $("#dialog").dialog({});
    });
    $('#editButton').click(function() {
        $('#refreshmydiv').load('/path/to/my/phpfile');
        $('#dialog').dialog("close");
    });
});​

这是html

<div id="dialog" style="display:none;">
    <div>
        Input Field1:<input type="text" id="xyz">
    </div>
    <div>
        InPut Field2: <input type="text" id="abc">
    </div>
    <div>
        <input type="submit" id="editButton" value="Edit">
    </div>
</div>
<div id="refreshmydiv">
<table class="table table-striped" id="authentication">
    <thead>
        <tr>
            <th>Username</th>
            <th>Password</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach($user as $key=>$value){?>
        <tr class="rowData">
            <td class="username"><?php echo $key; ?>
            </td>
            <td class="password"><?php echo $value; ?>
            </td>
            <td><Button type="submit" class="btn">Edit</button>
            </td>
            <td>Delete
            </td>
        </tr>
        <?php  } ?>
    </tbody>
</table>
</div>

编辑

如果我取出

$('#refreshmydiv').load('/path/to/my/phpfile');

然后它就工作了。。。但我需要负荷。。。。

OK找到了解决方案。对话框将内容保留在正文之外,因此我们必须在加载之前将其删除。

以下是的作用

 $('#dialog').remove();
 $('#refreshmydiv').load('/path/to/my/phpfile');
 $('#dialog').dialog("close");

谢谢各位

相关内容

最新更新