我有以下代码
HTML:
<div class="portlet-body">
<div class="table">
<table class="table table-advance table-hover">
<thead>
<tr>
<th><strong>#</strong></th>
<th><strong>Status</strong></th>
<th><strong>Name</strong></th>
<th><strong>Mobile No</strong></th>
<th><strong>Phone No</strong></th>
<th><strong>Email</strong></th>
<th><strong>Litigation</strong></th>
<th><strong>Address</strong></th>
<th colspan="2"><strong>Actions</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><span class="label label-md label-danger">Rejected</span></td>
<td>Mr Name One Ahmed</td>
<td>441254226688</td>
<td>441254226688</td>
<td><a href="mailto:zeeah@mail.co.uk">zeeah@mail.co.uk</a></td>
<td>N/A</td>
<td>5 (Flat 12 ) Temple Street, <br />Nelson, Lanca's, BB95SS</td>
<form method="post" action="/legalHQ/public/admin/PIClaimant.php" class="mysubmitClass" id="deleteform" >
<td>
<input type="hidden" name="hidden_pi_claimant_id" value="9">
<input type="hidden" name="hidden_case_id" value="1">
<input type="submit" name="edit" id="btnEdit" class="btn purple btn-xs" value=" Edit " />
</td>
<td><input type="submit" name="delete" id="btnDelete" class="btn red btn-xs myconfirm" value=" Delete " /></td>
</form>
</td>
</tr>
<tr>
<td>2</td>
<td><span class="label label-md label-warning">Submitted</span></td>
<td>Mr Name Two Ahmed</td>
<td>441254226688</td>
<td>441254226688</td>
<td><a href="mailto:zeeah@mail.co.uk">zeeah@mail.co.uk</a></td>
<td>Yes Litigation</td>
<td>5 (Flat 2 ) Temple Street, <br />Nelson, Lanca's, BB95SS</td>
<form method="post" action="/legalHQ/public/admin/PIClaimant.php" class="mysubmitClass" id="deleteform " >
<td>
<input type="hidden" name="hidden_pi_claimant_id" value="10">
<input type="hidden" name="hidden_case_id" value="1">
<input type="submit" name="edit" id="btnEdit" class="btn purple btn-xs" value=" Edit " />
</td>
<td><input type="submit" name="delete" id="btnDelete" class="btn red btn-xs myconfirm" value=" Delete " /></td>
</form>
</td>
</tr>
<tr>
<td>3</td>
<td><span class="label label-md label-success">Accepted and Signed</span></td>
<td>Mr Name Five Ahmed</td>
<td>441254226688</td>
<td>441254226688</td>
<td><a href="mailto:zeeah@mail.co.uk">zeeah@mail.co.uk</a></td>
<td>N/A</td>
<td>33 Temple Street, <br />Nelson, Lanca's, BB95SS</td>
<form method="post" action="/legalHQ/public/admin/PIClaimant.php" class="mysubmitClass" id="deleteform " >
<td>
<input type="hidden" name="hidden_pi_claimant_id" value="12">
<input type="hidden" name="hidden_case_id" value="1">
<input type="submit" name="edit" id="btnEdit" class="btn purple btn-xs" value=" Edit " />
</td>
<td><input type="submit" name="delete" id="btnDelete" class="btn red btn-xs myconfirm" value=" Delete " /></td>
</form>
</td>
</tr>
<tr>
<td>4</td>
<td><span class="label label-md label-success">Accepted</span></td>
<td>Mr Name Seven Ahmed</td>
<td>441254226688</td>
<td>441254226688</td>
<td><a href="mailto:zeeah@mail.co.uk">zeeah@mail.co.uk</a></td>
<td>N/A</td>
<td>5 (Flat 2 ) Temple Street, <br />Nelson, Lanca's, BB95SS</td>
<form method="post" action="/legalHQ/public/admin/PIClaimant.php" class="mysubmitClass" id="deleteform " >
<td>
<input type="hidden" name="hidden_pi_claimant_id" value="13">
<input type="hidden" name="hidden_case_id" value="1">
<input type="submit" name="edit" id="btnEdit" class="btn purple btn-xs" value=" Edit " />
</td>
<td><input type="submit" name="delete" id="btnDelete" class="btn red btn-xs myconfirm" value=" Delete " /></td>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
jQuery如下:
$('.myconfirm').click(function(){
bootbox.confirm("Are you sure?", function(result) {
alert("Confirm result: "+result);
// return (result) ? true : false;
});
});
现在我已经修改了所有表格和数据的代码,但是我想在确认对话框后删除记录,所以我问了这个问题。
bootbox工作正常,如果它没有包裹<form>
标签,但在内部时,它不起作用。我不知道是什么问题。
任何想法?
答案 0 :(得分:1)
工作小提琴fiddle
使用以下代码:
$('.myconfirm').click(function(e){
e.preventDefault();
bootbox.confirm("Are you sure?", function(result) {
// alert("Confirm result: "+result);
if(result==true){
$('form').submit();
}
// return (result) ? true : false;
});
});
在bootstrap中,单击“确认”框中的“哪个”按钮?它可以是Yes或No.如果结果为Yes,则提交表单。但是如果用户点击No / Cancel。不提交表单。