# Remote\_function and :with =\>

**URL:** <https://www.ruby-forum.com/t/remote-function-and-with/136986>\
**Category:** Rails\
**Created:** [May 7, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/remote-function-and-with/136986 "2008-05-07T23:10:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [May 7, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/remote-function-and-with/136986/1 "2008-05-07T23:10:37Z")

</div>

I need to have this remote\_function method return more than a single  
value. Right now I have it being called when an input field blurs but I  
need it to pass more than the value for that one input field - I need it  
to pass three values. Here is what I got:

remote\_function( :update =\> ‘h\_phone’, :url =\> { :action =\>  
‘set\_h\_phone’, :id  
=\> @user.id}, :with =\> "Form.Element.serialize(‘cc2’) )

For the :with, I have tried several variations such as:  
:with =\> “Form.Element.serialize(‘cc2’),  
Form.Element.serialize(‘cc3’)”

But that doesn’t work. Is there a way to do this? Thanks in advance,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [May 7, 2008, 11:16pm UTC](https://www.ruby-forum.com/t/remote-function-and-with/136986/2 "2008-05-07T23:16:47Z")

</div>

On 7 May 2008, at 22:10, Shandy N. wrote:

> =\> @user.id}, :with =\> "Form.Element.serialize(‘cc2’) )
> 
> For the :with, I have tried several variations such as:  
> :with =\> “Form.Element.serialize(‘cc2’),  
> Form.Element.serialize(‘cc3’)”

What are the values you need to pass (what are cc2, cc3 etc… ?)  
More generally what you pass to :with should be a query string, so for  
example Object.toQueryString({a: 1, b:2}) should work.  
Form.Element.serialize() does do that - it will create name=value  
pairs, but you do need to glue them together yourself.

Fred

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [May 7, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/remote-function-and-with/136986/3 "2008-05-07T23:51:12Z")

</div>

Frederick C. wrote:

> On 7 May 2008, at 22:10, Shandy N. wrote:
> 
> > =\> @user.id}, :with =\> "Form.Element.serialize(‘cc2’) )
> > 
> > For the :with, I have tried several variations such as:  
> > :with =\> “Form.Element.serialize(‘cc2’),  
> > Form.Element.serialize(‘cc3’)”
> 
> What are the values you need to pass (what are cc2, cc3 etc… ?)  
> More generally what you pass to :with should be a query string, so for  
> example Object.toQueryString({a: 1, b:2}) should work.  
> Form.Element.serialize() does do that - it will create name=value  
> pairs, but you do need to glue them together yourself.
> 
> Fred

I ended up using the :submit option. Those fields were for the three  
different parts of a phone field. Thanks for the help,

-S
