The jQuery datatable in the gaming infrastructure is $ ("# example"). DataTable is not a function

I am trying to implement jquery datatables in my game application.

Here is my code

#{extends 'main.html' /} #{set title:'Customers List' /} <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/demo_table.css'}"> <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/demo_page.css'}"> #{set 'moreScripts'} <script src="@{'/public/javascripts/jquery-1.5.2.min.js'}" type="text/javascript" charset="${_response_encoding}"></script> <script src="@{'/public/javascripts/jquery.dataTables.js'}" type="text/javascript" charset="${_response_encoding}"></script> <script src="@{'/public/javascripts/jquery.js'}" type="text/javascript" charset="${_response_encoding}"></script> <script> $(document).ready( function() { oTable = $('#example').dataTable(); }); </script> #{/set} <div class="others" align="center"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="example"> <thead> <tr> <th>Header1</th> <th>Header2</th> </tr> </thead> <tbody> <tr> <td>Col1</td> <td>Col2</td> </tr> </tbody> </table> </div> 

When I launch the page, javascript throws an error

 $("#example").dataTable is not a function 

I checked all javascript / css files. All files have been included. What could be a mistake.

+2
source share
2 answers

You must load the DataTables AFTER jQuery into your scripting section, and you should only include jQuery once.

Try removing the second (not reduced) query for jQuery and see how you go.

+12
source

There are only two causes of error.

+2
source

All Articles