Extend draw.dt Callback
Extend draw.dt Callback

Hi, I need help.
To get id and ajax data, we can do this:
$('body').on('draw.dt', function(e, ctx){
var api = new $.fn.dataTable.Api(ctx)
console.log('The ID : ', api.table().node().id)
console.log('The data: ', api.ajax.json())
})
I want to extend (without touching datatables.js) the draw.dt so that my team can do this:
$('body').on('draw.dt', function(e, ctx, id, data){
console.log('The ID : ', id)
console.log('The data: ', data)
})
This discussion has been closed.
Answers
You can't. The only way to add the DataTable API instance to the parameters of the event callback would be to modify the source.
The only other option would be to trigger your own event (
custom-draw
for example) from inside thedraw
event handler. Then you can pass your own parameters to it.Allan