Using multiple tables that share SOME settings
Using multiple tables that share SOME settings
On my site, I have many tables. Most of these tables share some general settings. Most also have some unique settings that apply only for that specific table. How can I implement this in a smart way, in order to avoid having to repeat my code?
For example, all tables I use, have pagination, but not all use "full_numbers". Some use "simple".
I also use the language setting to translate from default English to custom Swedish.
How can I set the translation of "Next" only ONE time in order to avoid repeating this translation for every table I have?
I tried as you would with CSS...
$ (#dt).DataTable() { some general settings shared by all tables with id = dt}
$ (#dt-unique).DataTable() { custom settings for dt-unique only}
... and then tried table id='dt dt-unique' but this does not seem to work.
I am fairly compentet with HTML and CSS, but only a jQuery / DataTables novice. I hope my question makes sense.
This question has an accepted answers - jump to answer
Answers
This might be useful:
http://datatables.net/examples/advanced_init/defaults.html
I use it myself, although I still haven't figured out how to "drop in" the occasional parameter which differs from my default setting.
Wow, thanks a lot Tang! I got it to work with no problem at all!
And as for how to implement, check out this fiddle http://jsfiddle.net/892xnbam/1/
Both tables now use the same translations.