{"id":209,"date":"2010-10-13T14:18:40","date_gmt":"2010-10-13T14:18:40","guid":{"rendered":"http:\/\/www.nirvaat.com\/?p=209"},"modified":"2010-10-13T14:20:58","modified_gmt":"2010-10-13T14:20:58","slug":"using-ajaxhelper-for-pagination-in-cakephp-1-3","status":"publish","type":"post","link":"https:\/\/nirvaat.com\/blogs\/2010\/10\/using-ajaxhelper-for-pagination-in-cakephp-1-3\/","title":{"rendered":"Using AjaxHelper for pagination in CakePHP 1.3"},"content":{"rendered":"<p>I am using CakePHP since last 5 years, and am quite used to of &#8220;AjaxHelper&#8221; for developing Ajax features using CakePHP. But from version 1.3 CakePHP has started deprecating the &#8220;AjaxHelper&#8221; replacing it with new &#8220;JsHelper&#8221;, which can be used with many JS libraries.<\/p>\n<p>While AjaxHelper is still there for people like me. There is at least one big change that I noticed just now. It is related with working of Ajax Pagination.<\/p>\n<p>Now the &#8220;Paginator&#8221; helper by default uses &#8220;JsHelper&#8221;, for generating the Javascript links. Now if you are trying to avoid using JQuery then you need some way to tell the &#8220;Paginator&#8221; helper to use &#8220;AjaxHelper&#8221; instead of JsHelper. Although the CakePHP documentation mentions that you can set the default helper value to Ajax Helper using following code, but it does not worked for me.<\/p>\n<p><code><br \/>\n$this-&gt;set('posts', $this-&gt;paginate());<br \/>\n\/\/Add this line below above line<br \/>\n$this-&gt;helpers['Paginator'] = array('ajax' =&gt; 'Ajax');<br \/>\n<\/code><\/p>\n<p>I tried it several times changing values and variables but no success.<\/p>\n<p>Instead of above you can use following two lines in the view file to tell the &#8220;Paginator&#8221;, to use Ajax helper.<\/p>\n<p><code><br \/>\n$this-&gt;Paginator-&gt;_ajaxHelperClass  = \"Ajax\";<br \/>\n$this-&gt;Paginator-&gt;Ajax = $this-&gt;Ajax;<br \/>\n$this-&gt;Paginator-&gt;options(array(\"update\" =&gt; \"\",'evalScripts' =&gt; true));<br \/>\n<\/code><\/p>\n<p>You also do <strong>NOT<\/strong> need to add the line<\/p>\n<p><code>echo $this-&gt;Js-&gt;writeBuffer();<\/code><\/p>\n<p>at the end of view file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am using CakePHP since last 5 years, and am quite used to of &#8220;AjaxHelper&#8221; for developing Ajax features using CakePHP. But from version 1.3 CakePHP has started deprecating the &#8220;AjaxHelper&#8221; replacing it with new &#8220;JsHelper&#8221;, which can be used with many JS libraries. While AjaxHelper is still there for people like me. There is [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[26],"tags":[38,37],"class_list":["post-209","post","type-post","status-publish","format-standard","hentry","category-quick-fixes","tag-ajaxhelper","tag-cakephp-ajax-pagination"],"_links":{"self":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts\/209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/comments?post=209"}],"version-history":[{"count":4,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":213,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts\/209\/revisions\/213"}],"wp:attachment":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/media?parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/categories?post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/tags?post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}