2
As I delete a row from a dynamic table through a confirmation dialog box (modal)?
So far I can delete only by directly using the delete button from the row itself in the table, but I wish there was a modal with a confirmation, before deleting it.
In the table comes a remove button then I click on it and opens a dialog asking:
" Are you sure you want to delete? Yes Not"
The problem is that I’m not getting to delete through this button Yes, only works when I click on the "remove" icon right in the table.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<table id="lista-tarefas" class="table table-bordered table-striped">
<thead class="bg-header-tb">
<th class="text-center text-uppercase">Nome</th>
<th class="text-center text-uppercase">Tipo</th>
<th class="text-center text-uppercase">Ação</th>
</thead>
<tbody>
<tr>
<td>Tarefa 1</td>
<td>Perguntas e Respostas</td>
<td class="text-center">
<p data-placement="top" data-toggle="tooltip" title="Editar" class="acoes-btn">
<button class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" >
<span class="glyphicon glyphicon-pencil"></span>
</button>
</p>
<p data-placement="top" data-toggle="tooltip" title="Excluir" class="acoes-btn">
<button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete">
<span class="glyphicon glyphicon-trash"></span></button>
</p>
</td>
</tr>
</tbody>
</table>
<!--caixa de dialogo-->
<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
<h4 class="modal-title custom_align" id="Heading">Excluir tarefa</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger"><span class="glyphicon glyphicon-warning-sign"></span> Tem certeza que deseja excluir a tarefa?</div>
</div>
<div class="modal-footer ">
<button type="button" class="btn btn-primary" data-dismiss="modal"><span class="glyphicon glyphicon-ok-sign"></span> Sim</button>
<button type="button" class="btn btn-primary" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Não</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
Hello Isabella Meirelles, can you tell exactly how this exclusion occurs?
– user60252
Hello @Leocaracciolo I will click on the delete icon in the table and will open a dialog box asking if I want to delete, then pressing on yes the row of the table I selected will be deleted, I can not do through the dialog box, only direct by the icon of the table
– Isa