Ajax分页追加元素而不是更新id [英] Ajax Pagination append the element instead of updating id

查看:64
本文介绍了Ajax分页追加元素而不是更新id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Cakephp应用程序。我要在这里创建Facebook风格的分页。我仍然在简单排序的Ajax分页上做了。现在,根据我的逻辑,我将创建下一步按钮。和渲染元素。 Cakephp本身将管理分页。但是我的问题是,它会在更新期间向我询问的特定div(ID)呈现我的视图。我的dom风格是...

I am working on Cakephp application. What I want here is to create facebook style pagination. Still I have done with Ajax pagination on simple sorting. Now my logic with this I will create button of next. and render element. Cakephp will itself manage pagination. But my issue is its rendering my view to particular div(ID) that it ask me during 'update'. My style of dom is...

<div class="fb_style" id='1'></div>
<div class="fb_style" id='2'></div>
<div class="fb_style" id='3'></div>
<div class="fb_style" id='4'></div>
<div class="fb_style" id='5'></div>
<div class="fb_style" id='6'></div>
<div id='more button'>MORE BUTTON(ACTUALLY PAGINATOR NEXT LINK)</div>

我想在id = 6旁边渲染div或在.fb_style:last旁边说
我的分页示例代码...我只是希望附加到特定的dom元素。

I want to render the div next to id=6 or I can say next to .fb_style:last My pagination sample code...I simple wish to append to particular dom element.

$this->Paginator->_ajaxHelperClass = "Ajax";
$this->Paginator->Ajax = $this->Ajax;
$this->Paginator->options(array('update' => 'listID',
    'url' => array('controller' => 'poets', 'action' => 'index', $separator),
    'indicator' => 'loaderID'));

如果我使用Jquery进行操作,则意味着要编写函数,而不是笨拙的方式,我必须发送总记录,而不是手动验证该限制,因此在查看时检查总记录是否相等或更多,因此我以上述逻辑让我知道它是否正确...或任何其他解决方案或指南。

If I do it with Jquery means to write function than its quite clumpsy means I have to send total records, than validate the limit manually, on view check if total records are equal or more so I move with above logic let me know if it correct...or any other solution or guide line with it.

推荐答案

我使用了无限滚动的JQuery插件,效果很好。这个jquery插件将为您提供自定义的内置事件,您可以使用这些事件将Ajax请求发送到控制器的方法。另外,如果它可以正常工作,则可以将其更改为类似于Facebook无限滚动功能的CSS。

I used Infinite scrolling JQuery plugin and it is just working fine. This jquery plugin will give you custom built-in events that you can use to send Ajax request to your controller's method. Also if it will be working then you can change it css to looks like facebook infinite scrolling functionality.

这里是另一篇文章,它将帮助您如何在CakePHP中使用它。

Here is another post that will help you how to use it with CakePHP.

这篇关于Ajax分页追加元素而不是更新id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆