# Few Questions about form\_for\_remote

**URL:** <https://www.ruby-forum.com/t/few-questions-about-form-for-remote/163871>\
**Category:** Rails\
**Created:** [March 25, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/few-questions-about-form-for-remote/163871 "2009-03-25T18:23:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tashfeen.ekram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3ab097/32.png) [@tashfeen.ekram](https://www.ruby-forum.com/u/tashfeen.ekram)\
**Post date:** [March 25, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/few-questions-about-form-for-remote/163871/1 "2009-03-25T18:23:02Z")

</div>

Still learning some stuff so forgive the newbie type questions.

1. if i use the :update param on form\_for\_remote can I mix javascript  
and ruby? i want to use the selector offered by prototype but pass in  
the parameters from a ruby expression

\<% form\_remote\_for(userdrug, :loading =\> “$(‘XXXX’).show();” + “alert  
(‘hi’);” do |f| %\>

I would basically like in where XXXX is to have an ruby expression  
like object.id

1. Can you use RJS commands for :loading ? seems like not ☹

2. for the button:

\<%= f.submit “Update”, :disable\_with =\> “Please wait…” %\>

I would like it to be disabled until the request ir returned however  
using the above only disables it momentrily whil it is sending the  
request and then it can be pressed again even before the sever  
responds.

Thanks!

---

<div class="post-metadata">

**Author:** ![tashfeen.ekram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3ab097/32.png) [@tashfeen.ekram](https://www.ruby-forum.com/u/tashfeen.ekram)\
**Post date:** [March 25, 2009, 7:13pm UTC](https://www.ruby-forum.com/t/few-questions-about-form-for-remote/163871/2 "2009-03-25T19:13:01Z")

</div>

figured out answer to the first one:

\<% form\_remote\_for(userdrug, :loading =\> “$(’” + user.id + “’).show  
();” + “alert(‘hi’);” do |f| %\>

---

<div class="post-metadata">

**Author:** ![tashfeen.ekram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3ab097/32.png) [@tashfeen.ekram](https://www.ruby-forum.com/u/tashfeen.ekram)\
**Post date:** [March 25, 2009, 7:18pm UTC](https://www.ruby-forum.com/t/few-questions-about-form-for-remote/163871/3 "2009-03-25T19:18:19Z")

</div>

On Mar 25, 5:22 pm, “tashfeen.ekram” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> like object.id  
> That’s a ruby string, you can put whatever ruby expression you want  
> (of course this is evaluated when the template is rendered, not when  
> you press submit

> 1. Can you use RJS commands for :loading ? seems like not ☹

You can via update\_page (an ajax responder is often cleaner though).  
You’ll write better JS once you get over RJS

> 1. for the button:
> 
> \<%= f.submit “Update”, :disable\_with =\> “Please wait…” %\>
> 
> I would like it to be disabled until the request ir returned however  
> using the above only disables it momentrily whil it is sending the  
> request and then it can be pressed again even before the sever  
> responds.

Personally I would do that via an ajax callback. The code for submit  
looks it would undisable the button if the onsubmit returns false  
(which the one remote\_form\_for will do since it’s preventing the  
browser from submitting the form normally)

Fred

---

<div class="post-metadata">

**Author:** ![tashfeen.ekram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3ab097/32.png) [@tashfeen.ekram](https://www.ruby-forum.com/u/tashfeen.ekram)\
**Post date:** [March 25, 2009, 7:33pm UTC](https://www.ruby-forum.com/t/few-questions-about-form-for-remote/163871/4 "2009-03-25T19:33:01Z")

</div>

On Wed, Mar 25, 2009 at 12:22 PM, tashfeen.ekram  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. if i use the :update param on form\_for\_remote can I mix javascript  
> and ruby? i want to use the selector offered by prototype but pass in  
> the parameters from a ruby expression

You can, but in some case you may find an RJS template easier to deal  
with, especially if you have complex logic after the form post. I  
usually just use :loading and :completed in my form tag and then do my  
update using replace\_html instead of :update.

> 1. Can you use RJS commands for :loading ? seems like not ☹

I’ve never tried, but yeah I think not also.

> 1. for the button:
> 
> \<%= f.submit “Update”, :disable\_with =\> “Please wait…” %\>
> 
> I would like it to be disabled until the request ir returned however  
> using the above only disables it momentrily whil it is sending the  
> request and then it can be pressed again even before the sever  
> responds.

That sounds like a bug to me.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
