'Cannot reinitialize' warning using reference to dataTable defined with no arguments

'Cannot reinitialize' warning using reference to dataTable defined with no arguments

jeffwjeffw Posts: 38Questions: 5Answers: 0
edited May 2014 in DataTables 1.9

For some reason this syntax is now triggering the Cannot Reinitialize DataTable warning:

var oTable = $('#tblEmailRecipients').dataTable();

I've used this elsewhere, and it's worked fine. The only thing I can think of that's different is that it's working fine when called inside an ajax call as part of the success() function, and here it's running at the top of $(document).ready() i.e. in query's top-level (global, sort of) namespace.

Does using the $().dataTable() call to get a reference to a table work only when it's inside functions? or is there some other reason this works in some places and not in others? I'm using dataTables 1.9.4.

Replies

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Can you link to a test page showing the issue please? You should be able to call the $().dataTable() constructor without parameters as many times as you want.

    A slightly pointless example, but it shows the point: http://live.datatables.net/puyofox/1/edit .

    Allan

  • jeffwjeffw Posts: 38Questions: 5Answers: 0

    The problem here was on my end, having to do with the order in which .js files were being loaded. It's working beautifully as planned. Especially the new API, e.g. being able to do things like

    oTable.$('td .myselector').prop('checked', true);

    Before I started using that i was doing a lot of manual paging. Worked, but the new way is so much better.

    Thank you again for such a great tool.

This discussion has been closed.