0

I have a problem with tablesorter. I delete rows without any problem, BUT when that row is a one that have been recently added, it doesn't work. I've been trying to solve this problem, but I can't.

This is my JS function:

$(function () {
        $('table').tablesorter({ theme: 'blue', widthFixed: true, widgets: ["zebra", "filter"] });

        $('#addbtn').click(function () {
            var idCliente = $("#Cliente").find('option:selected').val();
            var cliente = $("#Cliente").find('option:selected').text();
            var idConcepto = $("#Concepto").find('option:selected').val();
            var concepto = $("#Concepto").find('option:selected').text();
            var idSeccion = $("#Seccion").find('option:selected').val();
            var seccion = $("#Seccion").find('option:selected').text();
            var idMes = $("#Mes").find('option:selected').val();
            var mes = $("#Mes").find('option:selected').text();
            var pesos = $("#pesos").val() == "" ? "0" : $("#pesos").val();
            var dolares = $("#dolares").val() == "" ? "0" : $("#dolares").val();
            if (!validarCarga(idCliente, idConcepto, idSeccion, idMes, pesos, dolares))
                return false;

            $.ajax({
                url: '@Url.Action("Add")',
                type: 'POST',
                dataType: 'json',
                data: { idCliente: idCliente, idConcepto: idConcepto, idSeccion: idSeccion, idMes: idMes, pesos: pesos, dolares: dolares },
                success: function (resultado) {
                    if (resultado != "") {
                        var idPresu = resultado;
                        var row = '<tr><td><img value=' + idPresu + ' src="@Url.Content("~/Content/img/EditBtn2.png")" class="edit" style="cursor:pointer"/> <img value=' + idPresu + ' src="@Url.Content("~/Content/img/DeleteBtn2.png")" class="remove" style="cursor:pointer"/></td><td name="' + cliente + '" value="' + idCliente + '">' + idCliente + '</td><td name="' + cliente + '" value="' + idCliente + '">' + cliente + '</td><td name="' + seccion + '" value="' + idSeccion + '">' + seccion + '</td><td name="' + concepto + '" value="' + idConcepto + '">' + concepto + '</td><td name="' + mes + '" value=       "' + idMes + '">' + mes + '</td><td name="' + pesos + '" value="' + pesos + '">' + pesos + '</td><td name="' + dolares + '" value="' + dolares + '">' + dolares + '</td></tr>',
                        $row = $(row);
                        $('table').find('tbody').append($row);
                        $('table').trigger('update');
                    } else {
                        alert(resultado);
                    }
                }
            });
        });

$('img.remove').click(function () {
        var c = confirm("Desea eliminar el presupuesto?");
        if (c === false)
            return false;
        var $row = $(this);
        var idPresupuesto = $(this).attr("Value");
        $.ajax({
            url: '@Url.Action("Delete")',
            type: 'POST',
            dataType: 'json',
            data: { idPresupuesto: idPresupuesto },
            success: function (resultado) {
                if (resultado === "OK") {
                    var t = $('table');
                    t.trigger('disable.pager');
                    $row.closest('tr').remove();
                    t.trigger('enable.pager');
                } else {
                    alert(resultado);
                }
            }
        });
    });
    $('table').trigger("updateAll", true);
});

This is how it looks like... enter image description here

0 Answers0