Forum: Ruby on Rails form_remote_tag : additional onsubmit funct. possible ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andrew C. (Guest)
on 2006-04-10 20:19
Is there a way to add onsubmit functionality to a form_remote_tag with
an additional javascript directive?

eg I'd like for an inline javascript to make the form's div container
hidden as soon as the button is pressed to avoid having it possibly get
pressed again  ( sometimes the rails response is slow enough for a user
to think they need to re-press it ).

example:

<div id="form_container">

<%= form_remote_tag :url => { :action => 'do_stuff', :id => @stuff.id }
%>
<%= hidden_field_tag "info", @info %>
<%= text_field_tag "input_here", "0", :size => '5' %>
<input type="submit" value="DO_STUFF">
</form>

</div>

---


How would I modify the above ( if possible ) to add javascript to set
form_container to hide?

Thank You for any suggestions you can offer.
-Andy
Kevin O. (Guest)
on 2006-04-10 20:34
(Received via mailing list)
I'm not certain on this one, but I would wager that form_remote_tag
calls remote_function() at some point.

Try passing it a callback option like :before=>'some javascript'.


On Monday, April 10, 2006, at 6:19 PM, Andrew C. wrote:
>
>
>Posted via http://www.ruby-forum.com/.
>_______________________________________________
>Rails mailing list
>removed_email_address@domain.invalid
>http://lists.rubyonrails.org/mailman/listinfo/rails


_Kevin
Edward F. (Guest)
on 2006-04-10 20:37
(Received via mailing list)
Andrew,

Try:

> <%= form_remote_tag :url => { :action => 'do_stuff', :id => @stuff.id }, :loading => 
'somefunc();' %>


--

Ed Frederick -- edwardfrederick.com
Andrew C. (Guest)
on 2006-04-10 20:50
Thanks guys, looks like that should do ther trick.

Much appreciated!
Andy


Edward F. wrote:
> Andrew,
>
> Try:
>
>> <%= form_remote_tag :url => { :action => 'do_stuff', :id => @stuff.id }, :loading => 
'somefunc();' %>
>
>
> --
>
> Ed Frederick -- edwardfrederick.com
This topic is locked and can not be replied to.