I'm extending the DataTables defaults like so:
$.extend(true, $.fn.dataTable.defaults, {
lengthChange: false,
deferRender: true,
displayLength: 25,
stateSave: false,
serverSide: true,
processing: true,
ajax: {
type: 'POST',
error: function($xhr) {
if($xhr.status === 401) {
wxu.openLoginBox(function(data) {
// HELP: how can I get the DataTables object from this context?
});
} else {
wxu.notify({'text': "Could not load list", 'cssClass': 'error', timeout: 0});
}
}
}
});
Sometimes a user will get logged out and then when they try changing pages or sorting, it just says "Processing" forever. I can catch this by looking for a 401 error response (this is what my app sends when you've been timed out), but then I don't know how to "refresh" dataTables to make the "Processing" message go away so that you can resume using the app.
Please note that I'm extending the defaults here in a .js file -- I don't know what element DataTables is going to be bound to at this point.
How can I "fix" dataTables from inside the ajax/error callback?