我正在使用 jQuery DataTables 库为运行 Joomla 2.5 的网站上的表格设置样式。 http://datatables.net/
我遇到的问题是它不工作,但它也没有在萤火虫中给出任何类型的错误,所以我没有跟踪或任何东西。
我的表格的 HTML / PHP 是这样的:
<table class="staff_table">
<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>
<tr class="staff_table_head">
<td>Name</td>
<td>Job Title</td>
<td>Email Address</td>
</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>
我正在加载 jQuery 和 DataTables 库并在模板文件的 index.php 中像这样初始化它:
<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">
$(document).ready(function() {
$('#staff_table').dataTable();
} );
</script>
上面应该给我一些类似于以下内容的东西:
jQuery 确实可以正常工作,就好像我使用以下内容一样,它会按预期弹出一个框:
$(document).ready(function() {
alert('hi');
});
我什至尝试过 jQuery No Conflict,jQuery.noConflict();
在调用函数之前添加,但仍然没有,没有错误,没有工作。
编辑
如果我更改为以下内容,则会收到以下错误:
<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();
} );
</script>
这是我在 Firebug 中遇到的错误:
TypeError: oColumn is undefined
initialize(b=Object { tweakInitial={...}, tweakSubsequent={...}, tweakSizes={...}, more...}, a=Object { options={...}, element=ul.menutop, rtl=false, more...}, c=span#span- 1346841479204301.daddy)fusion.js (line 8)
initialize()mootools-more.js (line 27)
b()mootools-core.js (line 140)
g()mootools-core.js (line 135)
initialize(o=span#span-1346841479204301.daddy, m=1)fusion.js (line 8)
forEach(i=function(), v=Object { options={...}, element=ul.menutop, rtl=false, more...})mootools-core.js (line 39)
initialize(f="ul.menutop", k=Object { pill=0, effect="slide and fade", opacity=1, more...})fusion.js (line 8)
initialize()mootools-more.js (line 27)
b()mootools-core.js (line 140)
g()mootools-core.js (line 135)
(?)()school-staff (line 77)
fireEvent(f=function())mootools-core.js (line 370)
forEach(i=function(), v=Window school-staff)mootools-core.js (line 39)
fireEvent(e="domready", c=[], b=undefined)mootools-core.js (line 370)
g()mootools-core.js (line 507)
[Break On This Error]
...start({"margin-top":this.height,opacity:0}).chain(function(){if(this.childMenu.f...
fusion.js (line 8)