Get variable name assigned to a datatable
Get variable name assigned to a datatable
jvcunha
Posts: 81Questions: 10Answers: 1
It's possible get variable name assigned to a datatable ?
Example:
var tableXPTO1 = $('#myTableOne').DataTable({});
var tableXPTO2 = $('#myTableTwo').DataTable({});
$('body').on('init.dt', function (settings) {
identify variable name assigned to a datatable inside 'settings' (tableXPTO1 or tableXPTO2 ?)
}
Best regards,
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You wouldn't be able to get the variable name. That is a Javascript object which Datatables has no knowledge of.You could do something like this to get the
table
ID. Or simple just get an API instance to work with the Datatable.http://live.datatables.net/marizosi/1/edit
If this doesn't help then please explain what you want to do in the
init
event.Kevin
Hi Kevin,
I would like to set some common events only once for each table. Example:
No need to use:
The table variable is already in memory
Like I said the table variables are Javascript objects. Datatables has no knowledge of the variable name used. You can do something like this example:
http://live.datatables.net/marizosi/2/edit
It cascades the events and initializes Datatables. Within the events it uses jQuery to get the table being used via
$(this)
.Kevin
Thanks Kevin, best regards