Ideas for AJAX pagination

Hi,

I am looking for ideas on how to remove the last item from a
paginated page when a new item is inserted, thus leaving only 10
elements on the page.

Currently I have a form that inserts with AJAX, but as expected, each
post added to the page just increases the number of posts leaving 11
on a page that should only be displaying 10.

I have unique ID’s for each post (e.g. post_4, post_5, etc) and the
post with the lowest number is on the bottom of the page, can anyone
think of a way to make the last post disappear when the new post is
added?

Basically what i need to do is do a page.hide ‘page_<% lowest id %>’

  • where the lowest id is not a known integer.

Ideas?

~Jamie

On Friday, July 14, 2006, at 3:04 PM, Jamie Q. wrote:

I have unique ID’s for each post (e.g. post_4, post_5, etc) and the
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

You could just re-render the 10 items on the page and replace all of
them.

_Kevin

This is what I am already doing, I just need a way to get the ID of
the last post so I can hide it when a new one is made. If I could get
the ID of the lowest post on the page I would be able to do that.

~Jamie

I’m no expert with Rails or Ruby (I’ve only been using it for about a
week),
but it sounds like you want to do something like this:
http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates

Cody adds an item to the list but its always the same. To change it you
could just pass the post details through the action then page.hide "
page_#{@lowest_id}" and then page.insert_html “page_#{@newpost.title” or
something. (The syntax for insert_html isn’t correct, but you should get
the
idea)

Thought it might help! It probably won’t but that’s where I’d start.

Chris

On 15 Jul 2006 00:20:18 -0000, Kevin O. <

I guess I would save the scriptaculous overhead if I did it this way,
but it seems like re-rendering everything would defeat the purpose of
using ajax in the first place (avert unnecessary page-loads and
provide a smooth UI).

~Jamie

When the controller saves the actual record, the instance variable
that contains the record should have the ID now.

@post = Post.new(params[:post])
@post.save
@last_post_id = @post.id

Then in the data loaded by the remote form you could simply:

Element.hide(“post_<%= @last_post_id %>”)

Hope this helps,
Rick Martinez

On 7/16/06, Jamie Q. [email protected] wrote:

but it sounds like you want to do something like this:
Chris

elements on the page.
Basically what i need to do is do a page.hide ‘page_<% lowest id %>’
You could just re-render the 10 items on the page and replace all of them.

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Rick Martinez
Director of Technology
Complexity Gaming

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs