lit*_*had 5 javascript php datatable jquery cakephp
我正在尝试在我的cakePHP网站上实现jquery数据表,但它只是不会加载.这个网站已经开发了一半,从我看到的方式来看,js'是通过一个_head.inc.ctp位于views/layouts文件夹内的文件加载的,我在libs文件夹中添加了datatables库,webroot/js/libs并将其加载到_head.inc.ctp文件中.
假设我有这个:我的控制器:
var $helpers = array(
'Form',
'Html',
'Javascript'
);
//my method
function dataTable_example($id=null){
$details = $this->Detail->find("all");
$this->set('details', $details );
}
Run Code Online (Sandbox Code Playgroud)
我的看法:
<div>
<?php echo $javascript->link('libs/jquery.dataTables.js'); ?>
<script>
$(document).ready(function(){
$('#js-datatable').dataTable();
});
</script>
<h2><?php echo __l('Tickets');?></h2>
<div>
<table id="js-datatable">
<tr>
<th>some heading 1</th>
<th>some heading 1</th>
<th>some heading 1</th>
</tr>
<?php
if (!empty($details)){
foreach ($details as $detail):
?>
<tr>
<td><?php echo $detail['Detail']['id'];?></td>
<td><?php echo $detail['Detail']['created'];?></td>
<td><?php echo $detail['Detail']['ticket_detail'];?></td>
</tr>
<?php
endforeach;
}else{
?>
<tr>
<td>No Data Found</td>
</tr>
<?php }?>
</table>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我甚至使用通常的调用对它进行了硬编码,并使用firebug检查它是否加载了脚本,并且根据firebug,它被加载,所以我无法看到什么使脚本失败我的表.
我错过了一些步骤吗?请帮忙
谢谢