dimanche 10 juillet 2016

Disabled href on datatable script

I have a table that is fill dynamically, im using codeigniter and jquery and a template. The template is works with datatable.net v1.9 api I have created this script - The script disabled the column which contain href field, asociated to a condition. The script works, but the problem is: the return function not work on columns that are paginated. The script is like that, to repare the loop closure issue

$(function() {
var indice = <?php echo json_encode($acum);?>;
var table = $('#dt_a').DataTable();
var j=0;
var nodes = new Array();//
for(var i = 0;  i < indice.length; i++)
{   j=i+1;
    nodes.push(table.fnGetData(i )[4]);
      $('#mostrar'+j).click(
        function(num) {
        return function () {
            if(table.fnGetData(num )[4] == 1)
                alert('El usuario seleccionado tiene asociado un Loteo, para primero elimine el Loteo para poder eliminar el usuario');
                return false; }

    }(i)
  )
}});

Aucun commentaire:

Enregistrer un commentaire