【发布时间】:2014-07-05 18:36:07
【问题描述】:
我正在努力让 cakephp 工作的一些 ajax 分页。我已阅读说明here 和互联网上的其他各种页面,例如:SO link
但是我在控制台中遇到错误:
Uncaught type error undefined is not a function
这发生在$this->Js->writeBuffer() 生成的$(document).ready() 函数上。
关于我做错了什么有什么想法吗?
在我看来index.ctp我设置了分页器的选项:
$this->Paginator->options(array(
'update' => '#content',
'evalScripts' => true)
);
然后继续视图的其余部分,特别是我渲染表格。控制器已获取要显示的数据。
我输出我的分页控件:
echo $this->Paginator->prev();
echo $this->Paginator->numbers();
echo $this->Paginator->next();
在我的观点结束时,我会这样做:
echo $this->Js->writeBuffer();
我已将相关的助手和组件添加到我的控制器中:
public $helpers = array('Js' => array('jquery'));
public $components = array(
'Paginator',
'RequestHandler'
);
在default.ctp 中,我通过将其添加到 HTML 的末尾(就在 </body> 之前:
<script src="https://code.jquery.com/jquery.js"></script>
看起来它的工作原理是它生成了相关的 javascript 并为链接提供了 id,但单击链接就像正常工作一样。
【问题讨论】:
-
听起来你还没有包含 jQuery 或其他一些脚本调用
$.noConflict()。 -
@AD7six 你说得对,我已经更新了我的问题,使其更加全面。
-
html 输出会更相关 - 但这已经足够信息给您答案了。谢谢。
标签: ajax cakephp pagination