我有這樣的代碼:確認模式jQuery的引導
點擊此鏈接:
<td><?php echo anchor("atendimento/delete/{$record->id}", 'Excluir', ['class'=>'btn btn-danger',
'name' => 'delete', 'id' => 'anchordelete']); ?></td>
顯示有兩個按鈕Sim
和Nao
,其中Sim
意味着是和Nao
一個模式是指號如果我點擊在Sim
需要從數據庫中刪除數據。
<div class="modal fade" role="dialog" id="myModal">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Atenção</h4>
</div>
<div class="modal-body">
<p id="confirm-message"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" id="confirm">Sim</button>
<button type="button" class="btn btn-default" data-dismiss="modal" id="cancel">Não</button>
</div>
</div>
</div>
</div>
jQuery(document).ready(function() {
$("a[name='delete']").on('click', function(e){
$("#confirm-message").html("Confirma a EXCLUSÃO do registro?");
$('#myModal').modal("show");
e.preventDefault();
});
$('#confirm').on('click', function(){
$("a[name='delete']").trigger('click');
$("a[name='delete']").removeAttr("name");
$('#myModal').modal("hide");
});
});
不工作,當我點擊Nao
,模態接近,但如果我在Sim
點擊,什麼都沒有發生。
編輯:
,這裏是我的PHP循環
<?php if(count($records)){ ?>
<?php foreach($records as $record) {?>
<tr>
<td><?php echo $record->data; ?></td>
<td><?php echo $record->assunto; ?></td>
<td><?php echo $record->responsavel; ?></td>
<td><?php echo anchor("atendimento/edit/{$record->id}", 'Atualizar', ['class'=>'btn btn-success']); ?> </td>
<td><?php echo anchor("atendimento/delete/{$record->id}", 'Excluir', ['class'=>'btn btn-danger',
'name' => 'delete', 'id' => 'anchordelete']); ?></td>
</tr>
<?php }?>
<?php } ?>
你有多個'#anchordelete'上點擊過的URL模式?你試過'$(「#anchordelete」)。trigger('click')'? – madalinivascu
你是對的一件事...我有多個ID相同的名稱..現在我編輯..但同樣的問題 – HawkB
你需要找到刪除按鈕基於確認按鈕 – madalinivascu