0

我有一个第一次工作正常的对话框,即当我单击其中的编辑按钮时,它关闭得很好。但是第二次,当我单击编辑按钮时它不起作用。

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

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

4

1 回答 1

4

OK found the solution. THe dialog box leaves the content outside the body, so we have to remove it before load.

here is what would do

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

Thanks guys

于 2012-07-10T20:21:47.953 回答