在cakephp 2.0中的Ajax分页/排序 [英] Ajax Paging/sorting in cakephp 2.0

查看:126
本文介绍了在cakephp 2.0中的Ajax分页/排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cakephp 2.0并尝试创建ajax分页,我不能在文档中读到传递此

  $ this-> Paginator-> options(
array('update'=>'#box',
'evalScripts'=> true,
'before'=> $ this-> Js-> get('#loaderIDast') - > effect('fadeIn',array('buffer'=> false)),
'complete'=> $ this-> ; Js-> get('#loaderIDast') - > effect('fadeOut',array('buffer'=> false)),
))
视图中的

将使paginaton帮助创建一个ajax链接,在我的case doesnt。
我在这里使用jQuery引擎。



在挖掘库文件时,我发现paginator是使用事件函数,这使得

  jQuery(#link-969794460)。bind(click,function(event){jQuery.ajax({beforeSend:function(XMLHttpRequest ){jQuery(#loaderIDast)。fadeIn();},complete:function(XMLHttpRequest,textStatus){jQuery(#loaderIDast)。fadeOut();},dataType:html,evalScripts:true,success :function(data,textStatus){jQuery(#box)。html(data);},url:\ / admin\ / user\ / manage_user\ / sort:User.name\ / direction :asc}); return false;}); 

这是不知何故在事件call.I不返回为什么任何一个有一个想法什么



尊重
Himanshu Sharma。

解决方案

实际上,在这里有一个例子。查找Ajax分页部分。



您需要:




  • 要在控制器中加载的RequestHandler组件。

  • 要在控制器中加载的Js助手。


  • 您需要编写Js缓冲区( $ this-> Js-> writeBuffer())在你的视图/布局。除非您在 AppController 中加载Js助手,否则建议将其放入您的视图中,否则 $ this-> Js

    本书中的示例使用jQuery并可以工作。


    I am using cakephp 2.0 and trying to create ajax paging which i cant in the documentation i read that passing this

    $this->Paginator->options(
                              array('update'=>'#box',
                                    'evalScripts' => true,
                                    'before' => $this->Js->get('#loaderIDast')->effect('fadeIn', array('buffer' => false)),
                                    'complete' => $this->Js->get('#loaderIDast')->effect('fadeOut', array('buffer' => false)),
                              ))
    

    in the view will make paginaton helper to create ajax link which in my case doesnt. I am using jQuery engine here.

    On digging the library files i came across that paginator is using the event function which is making this

    jQuery("#link-969794460").bind("click", function (event) {jQuery.ajax({beforeSend:function (XMLHttpRequest) {jQuery("#loaderIDast").fadeIn();}, complete:function (XMLHttpRequest, textStatus) {jQuery("#loaderIDast").fadeOut();}, dataType:"html", evalScripts:true, success:function (data, textStatus) {jQuery("#box").html(data);}, url:"\/admin\/user\/manage_user\/sort:User.name\/direction:asc"}); return false;});
    

    and this is somehow not returned in event call.I dont know why any one have an idea what i am missing?

    Regards Himanshu Sharma.

    解决方案

    Actually, there are example in the book here. Look for the Ajax Pagination section. Make sure to follow all of the directions and it'll work.

    You need:

    • The RequestHandler component to be loaded in your controller.
    • The Js Helper to be loaded in your controller.
    • You need to include jQuery in your view/layout.
    • And you need to write the Js buffer ($this->Js->writeBuffer()) in your view/layout. It'd suggest putting this in your view unless you load the Js helper in your AppController because otherwise $this->Js won't be defined.

    The example in the book uses jQuery and works.

    这篇关于在cakephp 2.0中的Ajax分页/排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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