Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert will_paginate and periodically...

Replytotopic

will_paginate and periodically_call_remote

Posted in Forums : Ask a Rails expert

 
Photo

Authority 0
Posting Rating 0
Sign in to rate this post

i have a small problem regarding using the will_paginate periodically_call_remote

i have a div which displays a collection of records and i’m using periodically_call_remote to update those records each interval … i have recently add paging functionality through using will_paginate plug-in but i have noticed the following problem when i click the next page the paging works fine but when the periodically_call_remote get called to update the div the pager keeps the correct page number but the page display all the records as is it’s being reset to page number one ? could anyone please help in this?

 
Me

Authority 62
Posting Rating 100
Sign in to rate this post

Make sure the params[:page] is included in the periodic remote call. If it’s not included, try adding it. That should help.

 
Photo

Authority 0
Posting Rating 0
Sign in to rate this post

how i can include it in periodic update ?

 
Me

Authority 62
Posting Rating 100
Sign in to rate this post

For every Ajax object in Prototype you can include a parameters option where you can specify additional request parameters. You should be able to set it there.

 
Photo

Authority 0
Posting Rating 0
Sign in to rate this post

i have tried to pass it using With option in periodically_call_remote function but didn’t work ? where exactly is should add it?

 
Me

Authority 62
Posting Rating 100
Sign in to rate this post

I’d probably have something like this:

<%= periodically_call_remote(:url => posts_path, :with => "'page=' + $$('div#postsPages span.current').first.innerHTML") %>

Or whichever seems appropriate with your CSS.

 
Photo

Authority 0
Posting Rating 0
Sign in to rate this post

i tried to do so actually but i can’t get the pager div as it’s render like

 
Me

Authority 62
Posting Rating 100
Sign in to rate this post

Erm, did you actually read the will_paginate docs/tutorials? It clearly gives you this example:

<%= will_paginate @posts, :id => 'wp_posts' %>

This sets the div’s id to postPages.

 
Photo

Authority 0
Posting Rating 0
Sign in to rate this post

i got it working thanks a lot , i have another question .. now I’m totally depend on page .current span to get the value of current page so if i change the paging style to next and previous buttons only i will not be able to get such value … do you have any suggestion in such case?

Replytotopic

Other Recent Topics

Ask a Rails expert : How to parse <pubdate> in RSS

Ask a Rails expert : Couldn't find Product without an ID

Ask a Rails expert : HTML to XML ---> get title & description

Ask a Rails expert : Accessing controller actions from scripted page?

Ask a Rails expert : seledted option for select_tag

Ask a Rails expert : Merging fields from two tables into one, including duplicates

Ask a Rails expert : saving has_many :through

Ask a Rails expert : Use Rails to develop sites for both Designer and Programmer

Ask a Rails expert : Rails+RS232

Ask a Rails expert : Is this a good way to add Admin section

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel