fnStandingRedraw calls increasing number of ajax requests

fnStandingRedraw calls increasing number of ajax requests

KonservinKonservin Posts: 4Questions: 1Answers: 0
edited April 2016 in Free community support

I have a peculiar problem with dataTable redrawing. My table shows a number of clients, and clicking on a client opens a bootstrap modal, where user can change all the fields. I need to show the changes upon closing the modal, so I use fnStandingRedraw on 'hidden.bs.modal'.

I works without fail, but what's peculiar is the number of ajax calls that keeps increasing linearily. After opening first client and closing it, one ajax request is made to 'libs/json/customers_resp.php'. After opening and closing two clients, two requests are made, and after 22 clients 22 requests are made.

Setting a breakpoint in console at userTable.fnStandingRedraw() shows that it's called only once (as it should), but resulting ajax requests keep increasing. Each request is identical except the 'sEcho'.

It maybe is not a problem with dataTables setup, but with what then?

var userTable = $('#customers_table').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "libs/json/customers_resp.php",
    "fnServerData": function(sSource, aoData, fnCallback, oSettings) {
        $.ajax({
            "dataType": 'json',
            url: sSource,
            type: "get",
            data: aoData,
            success: fnCallback
        });
    },
    aoColumns: [
        { bSortable: false, "sWidth":"2%" },    // No sorting for this columns, as it only contains checkboxes
        { bSortable: false, bVisible: false, "sWidth":"0%" }, // 1 ID
        <?php
        foreach ($db_strc as $value) {
            $sortable = ($value['sortable'] == 'Y') ? 'true' : 'false';
            $visible = ($value['visible'] == 'Y') ? 'true' : 'false';
            echo '{ bSortable: '.$sortable.' , bVisible: '.$visible.' ,"sWidth":"'.$value['width'].'%"},'."\n";
        }
        ?>
    ],
    sDom: '<"block-controls"l<"controls-buttons"p>>rti<"clear">',
    fnDrawCallback: function() {
        $('#customers_table').find('.open_client').parents('td').on("click", function(event){
            $(this).addClass('selected');
            target = userTable.fnGetData(this.parentElement)[1];
            openClient(target,'ex');
        });
    }
});

openClient(ID,mode) function is not relevant here, as it only opens the modal and does not interact with datatables. Redrawing the table is called thus:

    $(document).on('hidden.bs.modal', '.modal', function () {
        if (typeof(userTable) !== 'undefined') {
            userTable.fnStandingRedraw();
        }
    });

Everything works, but calls keep increasing, and after 100 clients it starts to affect on performance :) I really hope that someone will see what's going on here, and where I can look for a solution.

PS. using DataTables 1.10.7, jQuery v1.11.3

This discussion has been closed.