# Form\_remote\_tag : additional onsubmit funct. possible?

**URL:** <https://www.ruby-forum.com/t/form-remote-tag-additional-onsubmit-funct-possible/93800>\
**Category:** Rails\
**Created:** [April 10, 2006, 6:19pm UTC](https://www.ruby-forum.com/t/form-remote-tag-additional-onsubmit-funct-possible/93800 "2006-04-10T18:19:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aginghipster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@aginghipster](https://www.ruby-forum.com/u/aginghipster)\
**Post date:** [April 10, 2006, 6:19pm UTC](https://www.ruby-forum.com/t/form-remote-tag-additional-onsubmit-funct-possible/93800/1 "2006-04-10T18:19:11Z")

</div>

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:

\<%= form\_remote\_tag :url =\> { :action =\> ‘do\_stuff’, :id =\> @stuff.id }  
%\>  
\<%= hidden\_field\_tag “info”, @info %\>  
\<%= text\_field\_tag “input\_here”, “0”, :size =\> ‘5’ %\>

* * *

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

---

<div class="post-metadata">

**Author:** ![aginghipster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@aginghipster](https://www.ruby-forum.com/u/aginghipster)\
**Post date:** [April 10, 2006, 6:34pm UTC](https://www.ruby-forum.com/t/form-remote-tag-additional-onsubmit-funct-possible/93800/2 "2006-04-10T18:34:03Z")

</div>

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/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

\_Kevin

---

<div class="post-metadata">

**Author:** ![aginghipster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@aginghipster](https://www.ruby-forum.com/u/aginghipster)\
**Post date:** [April 10, 2006, 6:37pm UTC](https://www.ruby-forum.com/t/form-remote-tag-additional-onsubmit-funct-possible/93800/3 "2006-04-10T18:37:14Z")

</div>

Andrew,

Try:

> \<%= form\_remote\_tag :url =\> { :action =\> ‘do\_stuff’, :id =\> @stuff.id }, :loading =\> ‘somefunc();’ %\>

–

Ed Frederick – [edwardfrederick.com](http://edwardfrederick.com)

---

<div class="post-metadata">

**Author:** ![aginghipster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@aginghipster](https://www.ruby-forum.com/u/aginghipster)\
**Post date:** [April 10, 2006, 6:50pm UTC](https://www.ruby-forum.com/t/form-remote-tag-additional-onsubmit-funct-possible/93800/4 "2006-04-10T18:50:46Z")

</div>

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](http://edwardfrederick.com)
