문제

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.

다른 팁

Please don't forget to add the $this->Paginator->numbers() after you tell pagination helper that you want a javascript link instead of plain html

    <?php
$this->Paginator->options(array(
        'update' => '#content',
        'evalScripts' => true,
        'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
        'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
    ));
    ?>
    <?php echo $this->Paginator->numbers();?>

I had same problem but in my case the id of the div tag in layout file was wrong. It should be "content".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top