# Will Paginate and formatted JS calls

**URL:** <https://www.ruby-forum.com/t/will-paginate-and-formatted-js-calls/144746>\
**Category:** Rails\
**Created:** [August 1, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/will-paginate-and-formatted-js-calls/144746 "2008-08-01T18:18:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [August 1, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/will-paginate-and-formatted-js-calls/144746/1 "2008-08-01T18:18:28Z")

</div>

Once again I go to the RoR group for help.

I have an application that is completely RESTful. I have a formatted  
call to one of my resources that is;

format.js

and it calls and RJS file that reloads all the partials on the page  
and displays some new information. ( in this case it’s service  
tickets, and when I click on a specific radio box it loads some  
different tickets )

My problem is that it would seem that Will Paginate makes use of  
calling tickets.js when it’s trying to paginate through the  
tickets… and the format.js line in my index action for the tickets  
controller is causing the pagination not to work… instead I get a  
ton of Javascript on the screen.

If I remove the format.js line from the index action, the pagination  
works… but then my radio buttons don’t cause the AJAX reload.

My question is, how can I get around this? Should I make a new  
formatted type for the AJAX call, or is there some other way of  
getting around this. like if it’s will paginate, then format.js  
returns the next 10 tickets and if it’s the radio box calling  
format.js then it runs the index.rjs file? Maybe through params?

Any help would be appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [August 1, 2008, 6:31pm UTC](https://www.ruby-forum.com/t/will-paginate-and-formatted-js-calls/144746/2 "2008-08-01T18:31:23Z")

</div>

OK… apparently I’m not paying attention…

Everything works fine UNTIL I make a RJS call by clicking on the radio  
boxes… then the will paginate links change from “ticket” to  
“ticket.js”.

I was reading this post [http://railsforum.com/viewtopic.php?pid=67434](http://railsforum.com/viewtopic.php?pid=67434)  
and it seems I have a similar problem… however… putting  
\<%= will\_paginate @tickets, :params =\> { :action =\> “index”} %\>  
made little difference,and the links still change from ticket to  
ticket.js

Any ideas guys?

---

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [August 1, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/will-paginate-and-formatted-js-calls/144746/3 "2008-08-01T18:43:40Z")

</div>

Sorry for the spam…

For google-foo and internet archivations I’ll post the solition  
here… just change the will paginate block to

\<%= will\_paginate @tickets, :params =\> { :format =\> “html”} %\>

which updates the format parameter to “html” and makes the linke  
tickets.html, instead of .js and all is well.

Sorry again for the spam… I wasted so much time mucking around with  
it, figures when I finally go to the well, the solution comes to me.
