【问题标题】:dialog box closes on first time but not on second time对话框第一次关闭,但第二次不关闭
【发布时间】:2012-07-10 19:40:39
【问题描述】:

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

$(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');

然后它工作...... 但我需要有负载....

【问题讨论】:

  • 加载的phpfile在页面中加载了什么?
  • 它将表格加载到 div 中
  • 你能发布一个它加载的样本吗?
  • 好的,我在 div 中添加了表格
  • ....

标签: jquery-ui jquery jquery-ui-dialog


【解决方案1】:

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

这是怎么做的

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

谢谢大家

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-27
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多