Using render in observe_field before

I want to use render(:partial => “loading”) in observe_field’s before.
For example:

Can not run

<%= observe_field ‘username’,
:on => ‘blur’,
:update => ‘check_username’,
:url => {:action => ‘check_username’},
:before =>
“$(‘check_username’).update(’#{render(:partial => “loading”)}’)”,
:with => ‘username’ -%>

AJAX part, generate two lines

Can run

<%= text_field_tag ‘username’ %>

<%= observe_field ‘username’,
:on => ‘blur’,
:update => ‘check_username’,
:url => {:action => ‘check_username’},
:before => “$(‘check_username’).update(’<img
src=”/images/loading.gif">Checking…’)",
:with => ‘username’ -%>

AJAX part, generate only one line

partial

<%= img_tag “/images/loading.gif” %>Loading…

you might consider including the loading stuff in a hidden div, and
then,
when you trigger something with the observe field, you can use some
javascript to show it. I think that this should work. Any other
thoughts?

On Thu, Apr 10, 2008 at 9:15 PM, Ray Sun
[email protected]

Exactly what Scott said. Put it in a hidden div and show the div with
ajax.

On Fri, Apr 18, 2008 at 11:01 AM, Scott Ballantyne
[email protected]
wrote:

For example:

AJAX part, generate only one line


Greg N.
Rails Developer & Designer
Owner, carbon8.us
Blog, 20seven.org

Good point Scott, however, I’m assuming since he’s using observe_field
that
he’s doing a round trip to process something.

On Fri, Apr 18, 2008 at 11:15 AM, Scott Ballantyne
[email protected]
wrote:

ajax.

On Thu, Apr 10, 2008 at 9:15 PM, Ray Sun <

             :url => {:action => 'check_username'},
             :update => 'check_username',

Owner, carbon8.us
Blog, 20seven.org


Greg N.
Rails Developer & Designer
Owner, carbon8.us
Blog, 20seven.org

I don’t think you need ajax, just javascript.
if using prototype something like
Element.show(‘loading’)
this should work if you have a div with an id that’s loading.
no need to make a round trip to the server.

On Fri, Apr 18, 2008 at 11:04 PM, Greg N. [email protected]

Good point, but the value of the loading div is its immediacy in the
user
experience. So using javascript rather than ajax even if there is a
trip to
the server still has the advantage of being faster.

On Sat, Apr 19, 2008 at 4:54 AM, Greg N. [email protected]