# Remote function

**URL:** <https://www.ruby-forum.com/t/remote-function/115003>\
**Category:** Rails\
**Created:** [September 19, 2007, 4:55pm UTC](https://www.ruby-forum.com/t/remote-function/115003 "2007-09-19T16:55:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snaggy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@snaggy](https://www.ruby-forum.com/u/snaggy)\
**Post date:** [September 19, 2007, 4:55pm UTC](https://www.ruby-forum.com/t/remote-function/115003/1 "2007-09-19T16:55:40Z")

</div>

I have a form to edit a page, with its nice save button. Since it’s in  
textile I’m writing a preview button which renders the content to html  
and put it in a div.

But, how can I pass to the remote function the current content of the  
text area?

something like this

remote function( update =\> mydiv, ulr =\> (:action =\> textiler),  
arguments =\> (text =\> textarea.value) )

of course that doesn’t work, just to make myself understood

bye  
thanks

---

<div class="post-metadata">

**Author:** ![snaggy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@snaggy](https://www.ruby-forum.com/u/snaggy)\
**Post date:** [September 19, 2007, 6:41pm UTC](https://www.ruby-forum.com/t/remote-function/115003/2 "2007-09-19T18:41:33Z")

</div>

Try something like this…

# In the view

link\_to\_remote ‘Select’,  
:url =\> {:action =\> ‘generate\_preview’},  
:with =\> “‘text\_area\_value=’ +  
document.getElementById(‘someTextAreaID’).value”

# In the controller

def generate\_preview  
textAreaValue = params[‘text\_area\_value’]

#other\_stuff  
end

The :with option isn’t very well documented… It works with  
link\_to\_remote, but doesn’t seem to work with form\_remote. It might  
work with some button\_\* helpers, or whatever… I don’t know.

---

<div class="post-metadata">

**Author:** ![snaggy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@snaggy](https://www.ruby-forum.com/u/snaggy)\
**Post date:** [September 20, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/remote-function/115003/3 "2007-09-20T16:23:38Z")

</div>

great it works like a charm!

thanks

On Sep 19, 6:41 pm, Dave S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
