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' %>
<span id="check_username"></span>
<%= 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...
on 10.04.2008 15:15
on 18.04.2008 17:02
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 <ruby-forum-incoming@andreas-s.net>
on 18.04.2008 17:04
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 <ussballantyne@gmail.com> wrote: > > For example: > > > > # AJAX part, generate only one line > -- Greg Newman Rails Developer & Designer Owner, carbon8.us Blog, 20seven.org
on 18.04.2008 17:16
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 Newman <gregoryjnewman@gmail.com>
on 18.04.2008 22:54
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 <ussballantyne@gmail.com> 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 Newman Rails Developer & Designer Owner, carbon8.us Blog, 20seven.org
on 19.04.2008 06:23
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 Newman <gregoryjnewman@gmail.com>