Detect if origin of call came from reload inside .on('processing.dt', (e, settings, processing)
Detect if origin of call came from reload inside .on('processing.dt', (e, settings, processing)
Is there a way to detect from the call stack if the preceding call originated from the initial loading of the data table or when the reload event (.DataTable().ajax.reload(null, false)) is fired?
I have a processing event (.on('processing.dt', function (e, settings, processing) {}) in place which runs as expected on initial loading. However, I'd like to perform some conditioning within this event, but only when the reload occurs. Are there any properties I can condition on when a reload occurs?
.on('processing.dt', function (e, settings, processing) {
if (processing) {
} else {
}
});
Answers
A global variable should work.
I don't believe there is anything that indicates what process invoked the
processing
event. It could be anything from an ajax load/reload, sorting, paging or searching the table. I took a brief look at thesettings
object passed intoprocessing
but didn't see anything useful. I may have missed it thoughProbably the easiest thing to do is to use a glabal variable flag that you set when using
ajax.reload()
then reset at the end of theprocessing
event.Kevin