Forum: Ruby on Rails AJAX and Smooth Paging

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
0fb0ef55f6ba19a3803d4f7ad447e506?d=identicon&s=25 Zack Hubert (Guest)
on 2006-05-15 18:39
(Received via mailing list)
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:

<div id="viewport" style="overflow:hidden">
<%= partial rendering goes here %>
// instead of a button put one of those throbbing progress marker images
// 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

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 topic is locked and can not be replied to.