I have a table, whose rows are added dynamically.
Each column has elements of type select
e input text
and the last column has a text "Eliminar"
, so that when the user hits click on said column, the row is deleted .
How can I disable the "Delete" so that the row is not deleted when clicking?
This is working with jquery
.
The column has the form:
<td class="eliminar">
Eliminar
</td>
The third column is:
<td class="eliminar">
Eliminar
</td>
When this column is clicked, the following is triggered:
$(document).on("click",".eliminar",function()
{
var parent = $(this).parents().get(0);
var fila=$(parent).attr('id');
$(parent).remove();
}
The question points to whether there is any attribute at the column level that can be reset so that the content is disabled and the actions are not executed when clicked.
For example, I have disabled the elements in the previous columns in the following way:
$("#tabla tbody tr").each(function ()
{
$(this).find("td:eq(0)").find("select").attr('disabled',true);
$(this).find("td:eq(1)").find("input").attr('disabled',true);
$(this).find("td:eq(2)").attr('disabled',true);
}
In the last line I show how I'm trying to disable the contents of the column, but it does not work.
I told you that I solved the issue by doing the following:
$("#tabla tbody tr").each(function ()
{
$(this).find("td:eq(0)").find("select").attr('disabled',true);
$(this).find("td:eq(1)").find("input").attr('disabled',true);
$(this).find("td:eq(2)").removeClass("eliminar");
That way, when you click on that column, because you do not have the class, you do not execute the actions in:
$(document).on("click",".eliminar",function()