ajax Object cannot be access from a derived instance of DataTables

ajax Object cannot be access from a derived instance of DataTables

mnrafgmnrafg Posts: 2Questions: 2Answers: 0
edited July 2018 in Free community support

I think my issue can be simplified by writing a few lines of code here.

// The IIFEs are used just for
// simulating the real scenario.
(function() {
    // Initializing DataTables
    // this is in a local scope in somewhere
    var dt = $('#my_table').dataTable({
        'select': 'single',
        'lengthChange': false
    });

    // Here I can access the ajax object
    // and it works fine.
    dt.ajax.reload();
})();

(function() {
    // Somewhere else in a scope other than above
    // I am trying to do as follow:
    $('#my_table').dataTable().ajax.reload();
    // but here I cannot access ajax object
})();

Another question is what is the difference between the following two approaches, are they the same?

// This works fine
$('#my_table').dataTable({
    // options...
});

// But this also works
$('#my_table').DataTable({
    // options...
});

Thanks in advance,
Any help will be greatly appreciated.
Nasir

Answers

This discussion has been closed.