I have a portlet and one of its JSP pages contains a table populated with java objects:
Here is a sample code:
<% {%>
<table id="logtable">
<thead>
<tr><th>From</th><th>To</th><th>Time</th></tr>
</thead>
<tbody>
<c:forEach var="message" items="${messages}">
<tr>
<td><c:out value="${message.sender}"/></td>
<td><c:out value="${message.receiver}"/></td>
<td><c:out value="${message.timestamp}"/></td>
</tr>
</c:forEach>
</tbody>
</table>
<% } %>
I would like to make this table a DataTable using JQuery DataTables plugin. I put the downloaded libraries in docroot/js folder in my Liferay portlet and set the path to it in Liferay-portlet.xml conf like this (as instructed in the tutorial I referenced):
<header-portal-javascript>/js/DataTables/media/js/jquery.js</header-portal-javascript>
<header-portal-javascript>/js/DataTables/media/js/jquery.dataTables.js</header-portal-javascript>
Now the magic part comes - how do I actually init the dataTable from my example?
I thought, that inserting the following script udner the table in my JSP (according to the tutorial) would do, but it does nothing:
<script>
$(document).ready( function () {
$('#logtable').dataTable();
} );
</script>
What did I do wrong? Perhaps I did something wrong with specifying the path to my JQuery libraries... or am using it wrong? Should I call this function somewhere else? I am a newbie when it comes to JS and Jquery (sorry for dummy question), I just need to get this one thing working...
EDIT: SOLVED by replacing <header-portal-javascript> with <header-portlet-javascript>