Possible to Initialise without the table having an ID?
Possible to Initialise without the table having an ID?
Hi there,
I'm wondering if it's possible to initialise DataTables on a table without using an ID for the table tag itself? I'm asking as I'm working with a CMS that has a certain type of table matrix field that I have no control over, so the best I can do is to surround the table in a div with a unique ID (it's otherwise well formatted, with a thead and tbody).
I was hoping to be able to use code like this to initialise it: $('#my-div table').dataTable... or $('table#my-div').dataTable...
But neither worked, so I thought I'd post to clarify that this won't work unless the table tag has an ID itself, or to find if there's another workaround for this.
Thanks for any help,
Stephen
I'm wondering if it's possible to initialise DataTables on a table without using an ID for the table tag itself? I'm asking as I'm working with a CMS that has a certain type of table matrix field that I have no control over, so the best I can do is to surround the table in a div with a unique ID (it's otherwise well formatted, with a thead and tbody).
I was hoping to be able to use code like this to initialise it: $('#my-div table').dataTable... or $('table#my-div').dataTable...
But neither worked, so I thought I'd post to clarify that this won't work unless the table tag has an ID itself, or to find if there's another workaround for this.
Thanks for any help,
Stephen
This discussion has been closed.
Replies
Allan
It now works! I'm not sure what went wrong the first time - probably a bug with your code... (joking!) :-)
I actually suspect I put the div around an 'if statement' rather than the table between the if statement... :)
Thanks,
Stephen