gpt4 book ai didi

php - jquery 数据表和 cakePHP

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:39:55 24 4
gpt4 key购买 nike

我正在尝试实现 jquery datatable ,在我的基于 cakePHP 的网站中,但它不会加载。这个网站已经开发了一半,从我的 Angular 来看,js'是通过位于 views/layouts 文件夹内的名为 _head.inc.ctp 的文件加载的,我在 libs 文件夹中添加了数据表库,该文件夹是 webroot/js/libs 并将其加载到 _head.inc.ctp 文件中。

假设我有这个:我的 Controller :

var $helpers = array(
'Form',
'Html',
'Javascript'
);
//my method
function dataTable_example($id=null){
$details = $this->Detail->find("all");
$this->set('details', $details );
}

我的看法:

<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>

我什至使用通常的调用对其进行了硬编码,并使用 firebug 检查脚本是否已加载,根据 firebug,它已加载,所以我看不出是什么导致脚本无法通过我的表。

我错过了一些步骤吗?请帮忙

谢谢

最佳答案

您没有作为 required by the datatables script 的 thead 和 tbody 元素

关于php - jquery 数据表和 cakePHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5068149/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com