問題描述
我在讓 jQuery Datatables 庫正確顯示在我的 Joomla 網站表格上時遇到問題.http://datatables.net
I am having a problem getting the jQuery Datatables library to show up properly on my Joomla website table. http://datatables.net
腳本對我的表格進行了一半的樣式設置,然后放棄了(我更改了表格標題顏色和文本顏色,但沒有數據表控件等).
The script is half styling my table and then giving up (I am getting the table header colour changed and text colour, but no datatables controls etc).
Firebug 也拋出以下錯誤:
Firebug is also throwing the following error:
TypeError: oColumn is undefined
在我的 Joomla 模板 index.php 中,我在 中有以下內容:
In my Joomla templates index.php I have the following in the <head>
:
<script src="./datatables/js/jquery.js" type="text/javascript"></script>
<script src="./datatables/js/jquery.dataTables.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#staff_table').dataTable({
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": true
} );
} );
</script>
HTML/PHP 看起來像這樣:
The HTML / PHP looks like this:
<h3>Members of Staff</h3>
<p>If you're looking for a member of staff at Tower Road Academy, you'll find their details here.</p>
<table class="staff_table" id="staff_table">
<tr class="staff_table_head">
<th>Name</th>
<th>Job Title</th>
<th>Email Address</th>
</tr>
<?php
$result = mysql_query("SELECT * FROM itsnb_chronoforms_data_addstaffmember");
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>' . $row['staff_name'] . '</td><td>' . $row['staff_job'] . '</td><td><a href=mailto:"' . $row['staff_email'] . '">' . $row['staff_email'] . '</a>' . '</td>';
echo '</tr>';
}
?>
</table>
推薦答案
為了使數據表正常工作,您的表必須使用正確的 For datatable to work properly, your tables must be constructed with a proper HTML 中的所有 DataTables 都需要一個 和
構建. 標簽.
<thead>
and <tbody>
tags.