AJAX and Smooth Paging

Apologies on the subject heading, I couldn’t really think of a concise
way to describe the problem I’m trying to solve. Here’s the idea:

I have an application that shows a bunch of text in a div (through a
partial) and currently has a next button (submit_form_tag) at the end
of that text to fetch the next bit of text which it grabs via the AJAX
helpers. However, I’d like that button to automatically activate as
soon as it’s visible within the div so that the next bit of text is
fetched without the user having to go click on it.

My current thought is to layout the page like:

<%= partial rendering goes here %> // instead of a button put one of those throbbing progress marker images here // that when it's within the visible portion of the viewport, trigger a remote_form_tag // that appends to the bottom of viewport the next bit, and hides the image

Is this the best way to do this? If so, how do I figure out whether
my image is within the viewport?

I know that Rico has the LiveGrid functionality which I could cobble
into place, but I’d rather not go through all the requirements it has.
I just want an action to take place when an image is in the viewport.

Thanks in advance!


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