在cakephp中隐藏/显示分页

时间:2013-05-24 08:02:32

标签: jquery cakephp cakephp-2.0 cakephp-1.3

隐藏/显示分页当你向下翻页“显示更多”按钮然后点击其他记录显示在同一页面上时,我需要开发像facebook这样的分页。还使用了jquery + ajax。

谢谢

1 个答案:

答案 0 :(得分:1)

您的控制器类看起来像:

class BooksController extends AppController
{
    var $components = array('RequestHandler');
    var $helpers = array('Html','Form','Javascript');
    var $paginate = array('order'=>array('Books.author'),'limit'=>'15');

        function list()
        {
                $data = $this->paginate();
                $this->set('books',$data);
        }

}
?>
The viewer class would be:
<?php
if (count($books)>0) {

?>
<div id="pagination">
<?php
      echo $paginator->prev(); 
      echo $paginator->numbers(array('separator'=>' - ')); 
      echo $paginator->next();
?>
</div>

<table>
<?php
      foreach ($books as $book) {
?>
   < tr >< td >.
function loadlist(href,divName) {    
    $(divName).load(href, {}, function(){
        var divPaginationLinks = divName+" #pagination a";
        $(divPaginationLinks).click(function() {     
            var thisHref = $(this).attr("href");
            loadlist(thisHref,divName);
            return false;
        });
    });
} 

<script type="text/javascript">
          $(document).ready(function() {
            loadlist("<?php echo $html->url(array('controller'=>'books','action'=>'list'));?>","#booklist");
             });
    </script>
<div id="booklist">

</div> 

你可以使用这个链接:bakery.cakephp.org/articles/view/advanced-pagination-1-2和http://develemental.com/posts/view/ajax-pagination-in-cakephp-using-a-jquery-scroll-event