how to know if reload is ended

how to know if reload is ended

LapointeLapointe Posts: 430Questions: 81Answers: 4

hello

I do set filter selector on initcomplete.
After ajax.reload, selectors are empty...
How to get the ajax reload complete ?
what event is triggeed when reload ended?
In the example, select is empty because evaluated before reload end

    tblOpe.on( 'select', function (e) {
        tblLot.ajax.reload();
        tblDoc.ajax.reload();

        tblLot.columns(<?php echo $FilterLotColumnList; ?>).every( function () {
            var column = this;
            var select = $('<select><option value=""></option></select>')
                .appendTo( $(column.footer()).empty() )
                .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex($(this).val());    
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                } );
                column.data().unique().sort().each( function ( d, j ) {
                    (d!=null) ? select.append( '<option value="'+d+'">'+d+'</option>' ):'';
                });
        });
    } );

Replies

  • allanallan Posts: 61,657Questions: 1Answers: 10,094 Site admin
    edited October 2019

    You need to wait for the Ajax reload to complete - that can be done by passing a callback as the first parameter to ajax.reload() - e.g.:

    tblLot.ajax.reload( function () {
     // ... rebuild select elements
    } );
    

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Thanks again

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    hi @allan
    Can't accept your answer as good.... no button to do this (accept answer)

    Thanks

This discussion has been closed.