Datatables not loading on table with ID = "exports"

Datatables not loading on table with ID = "exports"

juni_be_goodjuni_be_good Posts: 2Questions: 1Answers: 0

I want to report a very strange bug. I'm using DataTables 1.10.19 on several pages of my software already, and had trouble adding it to a new one. I had the following errors.

This seemed like a load order issue, which was weird because all Javascript files are loaded from a common template on all pages, always in the same order (jQuery > jQueryUI > DataTables > DataTables plugins).

<script src="../vendor/components/jquery/jquery.min.js" defer></script>
<script src="../vendor/components/jqueryui/jquery-ui.min.js" defer></script>
<script type="text/javascript" src="../vendor/datatables/datatables/media/js/jquery.dataTables.js" defer></script>
<script type="text/javascript" src="../vendor/drmonty/datatables-buttons/js/dataTables.buttons.js" defer></script>
<script type="text/javascript" src="../vendor/drmonty/datatables-buttons/js/buttons.html5.js" defer></script>

I decided to use the non minified jquery.datatables.js to see exactly what the error was, and ended up on the following line (38)

This property name, "exports", is exactly the ID I used for my table.

$('#exports').DataTable();

That was a strange coincidence, so I dediced to change this ID to something else, just in case... and everything works fine now !

So apparently, DataTables can't load on a table whose ID is exactly "exports".

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921
    Answer ✓

    So apparently, DataTables can't load on a table whose ID is exactly "exports".

    It works here:
    http://live.datatables.net/nikecabe/1/edit

    I would suspect these errors as the problem:

    Kevin

  • juni_be_goodjuni_be_good Posts: 2Questions: 1Answers: 0

    I completed your example to use the exact versions of all the JS files I use in my project and I could find a CDN for, it still works.

    http://live.datatables.net/nikecabe/3/edit

    The other errors you mention all point toward similar lines trying to use "module.exports" and failing, but in plugin files instead of main DataTables files.

    I suppose there is a conflict with another library or something else specific to my project. Feel free to close this thread, since my problem is solved and this is obviously not a DataTables bug.

This discussion has been closed.