Can't run .fnDraw()

Can't run .fnDraw()

jandantejandante Posts: 10Questions: 4Answers: 0

Hi,

I don't seem to be able to run fnDraw() => TypeError: tableRelations.fnDraw is not a function.

This is my initialisation code + the code that should do a fnDraw after my delete operation is finished:

  var tableRelations;
  tableRelations = $('#relations').DataTable({
    processing: true,
    serverSide: true,
    order: [ 1, 'asc' ],
    ajax: "php/datatables/get_relations.php",
    language: dutchDataTable
});

  $('#confirmed-delete').on('click', function(){
    var toDelete = $('#relations').find('.selected').attr('id');
    $.ajax({
        type: 'POST',
        url: 'php/delete_relation.php',
        data: {id: toDelete, links: linkedContact, tasks: tasksContact}
    }).done(function(data){
        if (data == 'success') {
            tableRelations.fnDraw();
            $('#confirm-delete').modal('hide');
            $(".selectedRelation").hide();
        } else {
            console.log('Error: ' + data);
        }
    });
});

I suppose this is something trivial, but I don't see the difference with examples here or on stack...

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited August 2014 Answer ✓

    Second top FAQ :-)

    Btw, I'd suggest using the new API - draw() rather than the old fn* functions. In which case $().DataTable() is the correct option to use.

    Allan

  • jandantejandante Posts: 10Questions: 4Answers: 0

    Thank you (again :)).

    I was indeed going for an API instance but used the wrong function :). Thanks!

This discussion has been closed.