# How to use will\_paginate with ajax

**URL:** <https://www.ruby-forum.com/t/how-to-use-will-paginate-with-ajax/131460>\
**Category:** Rails\
**Created:** [March 10, 2008, 11:16am UTC](https://www.ruby-forum.com/t/how-to-use-will-paginate-with-ajax/131460 "2008-03-10T11:16:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 10, 2008, 11:16am UTC](https://www.ruby-forum.com/t/how-to-use-will-paginate-with-ajax/131460/1 "2008-03-10T11:16:38Z")

</div>

Hi  
I have a tabbed view in the file show\_details.rhtml as follows

attachments—contacts

- Attachments
- Contacts

\<%= render :partial =\> 'service\_desk\_part/view\_sd\_attachment\_details'%\>

\<%= render :partial =\> 'service\_desk\_part/view\_sd\_contact\_details' %\>

When the page loads attachmens tab is highlightd…I have pagination for  
contacts(say 100 total contacts  
and pagination 20 item per page…And i implemented it with  
will\_paginate)…BUT MY PROBLEM IS WHEN PAGINATING contacts THE NEXT PAGE  
COMES BUT ATTACHMENT TAB IS HIGHLIGHTED NOT THE CONTACT TAB …AND ALL  
THE PAGE GET RELOADED AGAIN…HOW CAN  
I FIX THIS?

my controller as below

def show\_details

@sd\_ticket = ServiceDeskTicket.find(params[:id])  
@sd\_attachments=@sd\_ticket.service\_desk\_attachments.paginate :page =\>  
params[:page], :per\_page =\> 15  
@sd\_contacts=@sd\_ticket.contacts.paginate :page =\> params[:page],  
:per\_page =\> 20

end

In my view for contact (\_view\_sd\_contact\_details.rhtml) the pagination  
portion is  
\<%= will\_paginate @sd\_contacts %\>

Please help…  
Sijo
