Phalcon自动与jquery分页

我想像facebook分页一样实现分页。 在我的博客中我希望它将加载第一个3post然后当页面滚动到底部它将加载更多…我想要简单的jquery没有任何插件。 这就是为什么我试图遵循这个链接: 示例和example2但不知道如何使用phalcon分页jquery可行。

我的currnet配置如下:

[控制器]

$bloger = Blogs::find(["order" => "datetime DESC"]); $numberPage = $this->request->getQuery('page', 'int', 1); /** @var \Phalcon\Paginator\Adapter\Model $paginator */ $paginator = new \Phalcon\Paginator\Adapter\Model ([ 'data' => $bloger, 'limit' => 2, 'page' => $numberPage ]); // I am assigning this to an array, because I need the variables twice. $viewParameters = ['counts' => $bloger->count(), 'page' => $paginator->getPaginate()]; $this->view->setVars($viewParameters); // when we request a new page via ajax, we will render the page and return it if ($this->request->isAjax()) { echo $this->view->getRender('blog', 'index', $viewParameters); return false; } 

[伏特]

 
items as $bloger) { ?>

{{ link_to('blog/showfull/'~bloger.id,bloger.blog_title) }}

Posted : [ {{bloger.blog_author}} ] {{ bloger.datetime }}

<img src="https://stackoverflow.com/questions/38763123/phalcon-auto-pagination-with-jquery/uploads/blogs/blog_image); ?>"/>


{{bloger.blog_intro}}
{{bloger.blog_desc}}
{{bloger.blog_concl}}
tags); foreach ($tags as $taged) { ?> <a class="tagline" href="https://stackoverflow.com/questions/38763123/phalcon-auto-pagination-with-jquery/blog/tag/">

[Jquery的]

 $(document).ready(function() { //Begin var page = 1; var maxPages = {{ page.last }} ; $(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) { if(page == maxPages) { $('.loader').html('No More Post to Render').fadeIn(500); } page += 1; if(page <= maxPages){ $.ajax({ url: 'blog/index?page=' + page, success: function(data) { $('.blogItems').append(data); } }); } } }); //End }); 

在这段时间之后我得到了这个错误。 看图像:并打破decs排序顺序。 我认为内部index.volt的原因有loadpost.volt中的查询(在你的例子中是newpage.volt)。 这样它的查询可以单独进行两次。 而且在jquery“没有更多post没有显示”请告诉我如何解决?

在此处输入图像描述

它发生在滚动上

[Jquery属性id语法id错误]

在此处输入图像描述

我举了一个例子。 请注意,这是一个精简的示例,代码不完整但它应该工作。 您可能需要在此处或那里添加一些自己的代码。

[控制器]

 $bloger = Blogs::find(["order" => "datetime DESC"]); $numberPage = $this->request->getQuery('page', 'int', 1); /** @var \Phalcon\Paginator\Adapter\Model $paginator */ $paginator = new \Phalcon\Paginator\Adapter\Model ([ 'data' => $bloger, 'limit' => 2, 'page' => $numberPage ]); // I am assigning this to an array, because I need the variables twice. $viewParameters = ['counts' => $bloger->count(), 'page' => $paginator->getPaginate()]; $this->view->setVars($viewParameters); // when we request a new page via ajax, we will render the page and return it if ($this->request->isAjax()) { echo $this->view->getRender('blog', 'newpage', $viewParameters); return false; } 

[查看:博客/新页面]

 
items as $bloger) { ?>

{{ link_to('blog/showfull/'~bloger.id,bloger.btitle) }}

Posted : [ {{bloger.bauthor}} ] {{ bloger.datetime }}

{{ image('data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',"alt": "Blog Image","data-src":"uploads/blogs/"~bloger.bimage,"title":"Description for "~bloger.btitle) }}


{{bloger.bintro}}
{{bloger.bdesc}}
{{bloger.bconcl}}
tags); foreach ($tags as $taged) { ?>

[jquery:src =“/ path / to / other-jquery-stuff.js”]

  var page = 1; $(window).scroll(function() { if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) { if (page == maxPages) { $('.loader').html('No More Post to Render').fadeIn(500); } page += 1; if (page <= maxPages) { $.ajax({ url: '/demo/blog/index?page=' + page, success: function(data) { $('.blogContainer').append(data); } }); } } });