Pipeline function Javascript concept question
Pipeline function Javascript concept question
skluger
Posts: 1Questions: 1Answers: 0
https://datatables.net/examples/server_side/pipeline
I'm pretty sure this is a Javascript concept question but for the pipeline example, how do the cache variables inside the pipeline function maintain their values from previous calls if the pipeline function gets recalled on every table redraw?
Answers
Its all about the scope of the variables. Near the top of the pipeline function you'll see:
Those store the information about the last request. The function that is actually run when DataTables then executes the Ajax method has access to them (they are not new variables in that function - they are the variables that were set before).
I found this page which does a nice job of explaining scope in Javascript.
Does that make a bit more sense now? Happy to explain the pipeline function further if it would help.
Allan