On Mon, Feb 13, 2006 at 11:15:40PM -0500, Byron S. wrote:
} Ok, I’m missing something obvious but after some reasonable looking in
} Rails book (sorry haven’t gotten the cookbook yet) and these archives
} don’t see a solution to my question.
} What is the cleanest way to load a div via AJAX when the page loads -
} user action necessary. I don’t really want to hack in a hidden remote
} or link that is submitted or clicked on page load.
call it from the body tag’s onLoad handler. The second, and less
method is to embed the call in a script tag at the bottom of the HTML
The onLoad handler is guaranteed to fire after the page has been
loaded and laid out. Embedded scripts are run when they are encountered
any time thereafter, I believe, at the discretion of the browser, but
before the onLoad handler is called).
Of course, if you want to load a div when the page loads, it would make
great deal more sense to put the initial contents of the div directly in
the page rather than making a separate request for it.
} I like the thought of using AJAX vs partials or something since then I
} cache this widget separately and use on multiple pages.
It sounds like you really want a helper method, actually.