Ajax will_paginate and form_remote_tag search

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

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

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

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

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

http://weblog.redlinesoftware.com/2008/1/30/willpaginate-and-remote-links