简体   繁体   English

使用JQuery helper的CakePHP 1.3 Ajax分页

[英]CakePHP 1.3 Ajax pagination using JQuery helper

I am building a cake application using cake 1.3 and JS helper using JQuery. 我正在使用cake 1.3和使用JQuery的JS helper构建cake应用程序。 I followed the ajax pagination tutorial properly from cake's 1.3 tutorial however there is some issue. 我从Cake的1.3教程正确地遵循了Ajax分页教程,但是存在一些问题。 First page loads fine and when I click on pagination links, action is performed using Ajax however the next page is empty and then no other pagination link works (nothing happens on click). 第一页加载正常,当我单击分页链接时,使用Ajax执行操作,但是下一页为空,然后其他分页链接均无效(单击时无反应)。 I guess it's a pagination chaining issue however I am following the steps needed to chain the pages properly as mentioned in above tutorial. 我想这是一个分页链接问题,但是我正在按照上面的教程中所述正确链接页面所需的步骤。

One difference in my case is that I am not using the layout div's ID, instead I am using a div from view inside which I am looping through the data. 我的情况的一个区别是,我没有使用布局div的ID,而是从视图内部使用div遍历了数据。 This div contains the paginator options and pagination links so I guess it shouldn't be an issue. 这个div包含分页器选项和分页链接,所以我想这应该不是问题。

On the page you linked, there's a section that reads: 在您链接的页面上,有一个部分显示为:

You then create all the links as needed for your pagination features. 然后,您可以根据需要创建分页功能的所有链接。 Since the JsHelper automatically buffers all generated script content to reduce the number of tags in your source code you must call write the buffer out. 由于JsHelper会自动缓冲所有生成的脚本内容以减少源代码中的标记数,因此必须调用将缓冲区写出。 At the bottom of your view file. 在视图文件的底部。 Be sure to include: 确保包括:

echo $this->Js->writeBuffer();

If you omit this you will not be able to chain ajax pagination links. 如果您忽略此选项,则将无法链接ajax分页链接。 When you write the buffer, it is also cleared, so you don't have worry about the same Javascript being output twice. 当您写缓冲区时,它也会被清除,因此您不必担心同一Javascript会被两次输出。

This matches your symptoms pretty closely; 这与您的症状非常吻合; did you remember to follow this step? 您还记得要执行此步骤吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM