API: each() with tables()
API: each() with tables()

Here's an example from another thread including some JavaScript:
http://live.datatables.net/kifuguti/9/edit
I want to apply this JS to multiple tables at once. Here's my try:
http://live.datatables.net/juhigaya/1/edit
I'm applying DataTables by datatable
class.
This example doesn't output any errors, however, the JS doesn't work at all.
I guess my usage of each()
with tables()
is incorrect...
What is the proper way to use each()
with tables()
?
This question has an accepted answers - jump to answer
Answers
http://live.datatables.net/juhigaya/2/edit
It should be easier than that! You should be able to just use
table.columns().every()
but that doesn't appear to be changing context. I'll need to look into that.Using
iterator
is another option: http://live.datatables.net/juhigaya/3/editAllan
Hi @allan,
Thanks! These examples solved my issue.
@allan,
I found that when I applied "Internationalisation plug-in", the JS stopped working.
http://live.datatables.net/juhigaya/6/edit
Is there a way to fix this?
Hi @koonkoons ,
It's because you're using jQuery lite which doesn't support Ajax - see here when the full jQuery is being used.
Cheers,
Colin
Hi @colin,
Confirmed that I could prevent errors in console by using the full version of jQuery, however, the JavaScript still didn't work (no sorting icons).
http://live.datatables.net/silugoda/2/edit
You need to use
initComplete
, but keep in mind thatinitComplete
is triggered once for each table. So we can use the parameter passed to it to identify the table it needs to operate on.Allan
Thanks @allan !
It works.