I am working with a library that has custom callbacks.
var dataTable = $("table").DataTable({
//...
initComplete: function(settings, json){
console.log(this);
}
}
I am trying to externalize this initComplete callback. I defined a custom function:
var initCallback = function(settings, json){
console.log(this);
}
var dataTable = $("table").DataTable({
initComplete: initCallback
}
It does work, but this
does not point to the datatable
itself. Is there a way to bind this to initCallback so I can access it?
What you are looking for is the
bind
function, here is some info.Basically, you can do some like this:
What if you passed "this" into your external function?