# Ajax will\_paginate and form\_remote\_tag search

**URL:** <https://www.ruby-forum.com/t/ajax-will-paginate-and-form-remote-tag-search/129618>\
**Category:** Rails\
**Created:** [February 20, 2008, 4:29am UTC](https://www.ruby-forum.com/t/ajax-will-paginate-and-form-remote-tag-search/129618 "2008-02-20T04:29:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [February 20, 2008, 4:29am UTC](https://www.ruby-forum.com/t/ajax-will-paginate-and-form-remote-tag-search/129618/1 "2008-02-20T04:29:39Z")

</div>

I have a somewhat unusual set up of will\_paginate like this:

[http://www.railsontherun.com/2007/9/27/ajax-pagination-in-less-than-5-minutes](http://www.railsontherun.com/2007/9/27/ajax-pagination-in-less-than-5-minutes)

also I have an ajax based form\_remote\_tag that submits a keyword to the  
index page for searching. (it has to submit it to the index page and  
not some other action otherwise will\_paginate breaks)

Ideally I’d like to have both the keyword submit and the pagination  
actions return via Ajax (by updating a particular div on the page)  
however the response method that I seem to have to use for will\_paginate  
and for the keyword search seem to be incompatible.

For will\_paginate to work correctly I have to do something like this:

render :update do |page|  
page.replace\_html ‘photos’, :partial =\> “photos”  
end

for the keyword search to work correctly I have to do this

render :partial =\> ‘photos’, :collection =\> @photos

the render partial seems to break for will\_paginate whereas render  
:update for the keyword search seems to return javascript on the page  
like this "try { "

I hope this isn’t too confusing.

TIA,

GP

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [February 21, 2008, 1:55am UTC](https://www.ruby-forum.com/t/ajax-will-paginate-and-form-remote-tag-search/129618/2 "2008-02-21T01:55:02Z")

</div>

For the life of me I can’t understand why a Javascript request should be  
returned as HTML where i can see

try { Element.update("photos …

Is there some rule that says you can’t have a route that allows posts to  
index?  
Obviously will\_paginate seems to have managed it somehow…

Any help would be greatly appreciated.

Thanks,

GP

Grayson P. wrote:

> I have a somewhat unusual set up of will\_paginate like this:
> 
> [http://www.railsontherun.com/2007/9/27/ajax-pagination-in-less-than-5-minutes](http://www.railsontherun.com/2007/9/27/ajax-pagination-in-less-than-5-minutes)
> 
> also I have an ajax based form\_remote\_tag that submits a keyword to the  
> index page for searching. (it has to submit it to the index page and  
> not some other action otherwise will\_paginate breaks)
> 
> Ideally I’d like to have both the keyword submit and the pagination  
> actions return via Ajax (by updating a particular div on the page)  
> however the response method that I seem to have to use for will\_paginate  
> and for the keyword search seem to be incompatible.
> 
> For will\_paginate to work correctly I have to do something like this:
> 
> render :update do |page|  
> page.replace\_html ‘photos’, :partial =\> “photos”  
> end
> 
> for the keyword search to work correctly I have to do this
> 
> render :partial =\> ‘photos’, :collection =\> @photos
> 
> the render partial seems to break for will\_paginate whereas render  
> :update for the keyword search seems to return javascript on the page  
> like this "try { "
> 
> I hope this isn’t too confusing.
> 
> TIA,
> 
> GP

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [February 21, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/ajax-will-paginate-and-form-remote-tag-search/129618/3 "2008-02-21T20:18:56Z")

</div>

See the link below for how to use WillPaginate via xhr ajax requests:

[http://weblog.redlinesoftware.com/2008/1/30/willpaginate-and-remote-links](http://weblog.redlinesoftware.com/2008/1/30/willpaginate-and-remote-links)
