How to get datatable object when using multiple datatables?

How to get datatable object when using multiple datatables?

ladislav2ladislav2 Posts: 13Questions: 0Answers: 0
edited November 2013 in General
I have multiple datatables on my page and I have onclick events on every row. Is there any clean way how to get appropriate datatable object of the currently clicked table?

[code]
$(document).on("click", ".datatable tbody tr", function(e) {
var table = [get oTable object of the clicked table]
...
})
[/code]

UPDATE: Ok http://datatables.net/forums/discussion/comment/12531

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    [code]
    var table = $(this).parents('table').dataTable();
    [/code]

    will do the business. The `dataTable()` "constructor" will return the already created instance if the table has already been DataTables-ised"...

    Allan
This discussion has been closed.