Multiple .dataTable(); calls breaks it.

Multiple .dataTable(); calls breaks it.

jmbuytaertjmbuytaert Posts: 2Questions: 0Answers: 0
edited November 2013 in DataTables 1.9
I'm using jQuery to get the dataTables working, and it works fine when I'm only calling one of them. If I call the .dataTable(); function twice for different tables, it breaks.

If you look at the demo (see link below), you can see that I'm calling the .dataTable(); function twice. The first time is for a table that's on another page. I need to have separate dataTable(); functions called twice since they will have different sorting options.

If you remove the first dataTable(); function from the script, the second one will work.

Example: http://jsfiddle.net/q3F5m/
DataTables debugger link: http://debug.datatables.net/afogig

How can I make this work? Thanks for your help.

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    There is no table 'table.tableOnAnotherPage' on that page, so calling a DataTables API method on that table (you call fnSort) doesn't really make much sense. That's why its not working. Bizarrely this is the second time today this question has come up and I don't remember ever seeing a question like this before!

    The new API in 1.10 will be able to cope with this kind of thing, but the current API considers it to be an error.

    Allan
  • jmbuytaertjmbuytaert Posts: 2Questions: 0Answers: 0
    Thanks for the quick response Allan!
This discussion has been closed.