I have an ajax form built using form_remote_tag. On submit, the form
updates a div ("message"), which besides displaying a message also
displays a loading animation. I want to be able to hit submit again
(with new inputs) and display a new message - along with the loading
animation. My problem is that once I hit submit the second time, my
loading animation no longer appears. Is it because I am essentially
over writing the image tag? If so, what is a better way to display
animation and have it available on multiple submits? Here are excerpts
from my code:
view--->
<%= form_remote_tag(:update => "confirm",
:url => { :action => ''confirm_trade'' },
:loading =>
"Element.show(''search-indicator'')",
:complete => visual_effect(:highlight, "confirm", :duration
=> 3.0 ))%>
<snip>
<%= end_form_tag %>
<div id="confirm">
<%= image_tag("indicator.gif",
:id => ''search-indicator'',
:style => ''display:none'') %>
<%= @flash[''notice''] if
@flash[''notice''] %>
</div>
Controller ---->
def confirm_trade
<snip>
#enough cash?
if @trade.cash < total
render :inline => "Sorry, insufficient cash."
return
end
(note, if it doesn''t meat the above test then it will render a
partial...
render(:partial => ''confirm'')
end
My issue if someone doesn''t have enough cash, then I tell them using
Ajax "Sorry, insufficient cash" where upon I want them to be able to
re-submit a lower amount. That''s where the loading animation no longer
shows up.
Thanks very much,
Steve