Jquery CakePHP Ajax分页是否可以工作,但是否可以使用其他排序我做错了什么?

Jquery CakePHP Ajax分页是否可以工作,但是否可以使用其他排序我做错了什么?,jquery,ajax,cakephp,sorting,pagination,Jquery,Ajax,Cakephp,Sorting,Pagination,我设置了一些Ajax分页来对记录进行排序。它实际上按照预期工作,但以下情况除外: 1.在新页面加载时:单击并排序列将按预期显示指示器和排序 2.再次排序,并将其作为标准http请求处理。结果是排序的,但不是按Ajax排序的 3.第三次排序,Ajax恢复工作并按预期排序 每次Ajax、http、Ajax、http 我不明白为什么每隔单击一次就重置一次排序 birds\u controller.php function index() { $birds = $this->paginat

我设置了一些Ajax分页来对记录进行排序。它实际上按照预期工作,但以下情况除外:

1.在新页面加载时:单击并排序列将按预期显示指示器和排序

2.再次排序,并将其作为标准http请求处理。结果是排序的,但不是按Ajax排序的

3.第三次排序,Ajax恢复工作并按预期排序

每次Ajax、http、Ajax、http

我不明白为什么每隔单击一次就重置一次排序

birds\u controller.php

function index() {
    $birds = $this->paginate('Bird');
    $this->set(compact('birds', $birds));
}
<?php
$this->Paginator->options(array(
'update'      => '#birdTable',
'before'      => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer'    => false)),
'complete'    => $this->Js->get('#busy-indicator')->effect('fadeOut',   array('buffer' => false)),
));
echo $this->Html->image('indicator.gif', array('id' => 'busy-indicator', 'style' => '    display: none;'));
?>

<div id="birdTable">
...
index.ctp

function index() {
    $birds = $this->paginate('Bird');
    $this->set(compact('birds', $birds));
}
<?php
$this->Paginator->options(array(
'update'      => '#birdTable',
'before'      => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer'    => false)),
'complete'    => $this->Js->get('#busy-indicator')->effect('fadeOut',   array('buffer' => false)),
));
echo $this->Html->image('indicator.gif', array('id' => 'busy-indicator', 'style' => '    display: none;'));
?>

<div id="birdTable">
...

...

问题可能是返回表中的链接与原始表中的链接不同:当您单击分页器时,原始链接是AJAX,将检索具有非AJAX链接的新表。使用Firebug检查单击前后的表结构是否相同。如果这对发布更多代码没有帮助,那么分页视图就是这里的相关视图


还要记住执行
$this->helpers['Paginator']=array('ajax'=>'ajax')根据。

问题可能是返回表中的链接与原始表中的链接不同:当您单击分页器时,原始链接是AJAX,将检索具有非AJAX链接的新表。使用Firebug检查单击前后的表结构是否相同。如果这对发布更多代码没有帮助,那么分页视图就是这里的相关视图


还要记住执行
$this->helpers['Paginator']=array('ajax'=>'ajax')根据。

我解决了这个问题,但我不喜欢这个解决方案。这与我最初的猜测是一致的。缓冲区没有调用正确的数据,因此我添加了:

echo $this->Js->writeBuffer();
到index.ctp,现在它按预期工作。因此,我有一个缓冲区的副本仍然在我的默认以及其他脚本


似乎不正确,但至少它现在起作用了。

我解决了这个问题,但我不喜欢这个解决方案。这与我最初的猜测是一致的。缓冲区没有调用正确的数据,因此我添加了:

echo $this->Js->writeBuffer();
到index.ctp,现在它按预期工作。因此,我有一个缓冲区的副本仍然在我的默认以及其他脚本


看起来不太对,但至少现在可以用了。

谢谢Juhana,在发布这篇文章之前,我在我行动的各个方面都尝试过这个助手呼叫,但没有任何区别。我确实发现,当初始排序完成时,页面会在其内部重新加载,似乎是自身的一个副本,但它没有使用ajax分页加载。感谢Juhana,在本文之前,我在我的操作的所有区域都尝试了该helper调用,并且没有任何区别。我所发现的是,当初始排序完成时,页面会在其自身中重新加载,并看起来是自身的副本,但它不会使用ajax分页加载。