# Need help in Ajax Pagination

**URL:** <https://discuss.rubyonrails.org/t/need-help-in-ajax-pagination/21502>\
**Category:** rubyonrails-talk\
**Created:** [December 10, 2007, 10:15am UTC](https://discuss.rubyonrails.org/t/need-help-in-ajax-pagination/21502 "2007-12-10T10:15:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachin238](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@sachin238](https://discuss.rubyonrails.org/u/sachin238)\
**Post date:** [December 10, 2007, 10:15am UTC](https://discuss.rubyonrails.org/t/need-help-in-ajax-pagination/21502/1 "2007-12-10T10:15:14Z")

</div>

hi All,

i wants to implement ajax pagination but i am facing a lot of problem , i found i lots of links on google but their is no explanation like what object we have to pass and condition can any body help me out in this concern pls i need your help as soon as possible

thanks sachin

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [September 10, 2008, 11:46am UTC](https://discuss.rubyonrails.org/t/need-help-in-ajax-pagination/21502/2 "2008-09-10T11:46:06Z")

</div>

R U using will\_paginate?

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [September 10, 2008, 12:53pm UTC](https://discuss.rubyonrails.org/t/need-help-in-ajax-pagination/21502/3 "2008-09-10T12:53:46Z")

</div>

Sijo Kg wrote:

> R U using will\_paginate?

Hi, I am using normal pagination code in controller as

@photo\_pages ,@photos = paginate\_collection @profile\_user,:per\_page =\> 16,:page =\> @params[:page]

and in view using the code above specified.

Regards, kiran

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [September 11, 2008, 4:15am UTC](https://discuss.rubyonrails.org/t/need-help-in-ajax-pagination/21502/4 "2008-09-11T04:15:11Z")

</div>

Hi &nbsp;&nbsp;&nbsp;Add the following code to view\_helpers.rb .The file is in vendor/plugins/will\_paginate/lib/will\_paginate

&nbsp;&nbsp;&nbsp;def page\_link\_or\_span(page, span\_class = 'current', text = nil) &nbsp;&nbsp;&nbsp;&nbsp;text ||= page.to\_s &nbsp;&nbsp;&nbsp;&nbsp;if page and page != current\_page &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if update = @options[:update] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@template.link\_to\_remote text, :update =\> update, :url =\> url\_options(page) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@template.link\_to text, url\_options(page) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@template.content\_tag :span, text, :class =\> span\_class &nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;Then for ajax pagination in view do like \<%= will\_paginate @thecollectionyouwanttopaginate, :update=\>'div', :params=\>{:controller=\>'controller\_name',:action=\>'action\_name',:any\_additional\_parameters=\>@any\_additional\_parameters}, :container =\> false %\>

&nbsp;&nbsp;&nbsp;&nbsp;And for normal pagination do what you are currenly doing

Sijo
