# Link\_to\_function and link\_to\_remote

**URL:** <https://www.ruby-forum.com/t/link-to-function-and-link-to-remote/176022>\
**Category:** Rails\
**Created:** [September 23, 2009, 7:03pm UTC](https://www.ruby-forum.com/t/link-to-function-and-link-to-remote/176022 "2009-09-23T19:03:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cdc98d/32.png) [@vladk](https://www.ruby-forum.com/u/vladk)\
**Post date:** [September 23, 2009, 7:03pm UTC](https://www.ruby-forum.com/t/link-to-function-and-link-to-remote/176022/1 "2009-09-23T19:03:54Z")

</div>

Hi guys. I`m having this kind of problem:

i have the comments tree, there`s this link\_to\_function under each one:

link\_to\_function “Reply”,  
“$(‘comment\_parent\_id’).setValue(#{comment.id});”

as you see it simply passes comment.id to my form.  
Form looks like this :

\<%form\_for :comment, :url =\> {:controller =\>'events', :action =\>'post\_comment'} do |f| %\> \<%= f.hidden\_field :parent\_id, :value =\> nil %\> \<%= f.text\_area :comment %\>  
 \<%= f.submit "Add comment" %\> \<% end %\>

i render both form and comments from partials.

I need to somehow change this:  
link\_to\_function “Reply”,  
“$(‘comment\_parent\_id’).setValue(#{comment.id});”

to link\_to\_remote ( i want to open the form right under the comment  
after clicking the link) and keep the function to pass the comment.id

any ideas/theory/suggestions are much appreciated! Thanks!

---

<div class="post-metadata">

**Author:** ![vladk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cdc98d/32.png) [@vladk](https://www.ruby-forum.com/u/vladk)\
**Post date:** [September 23, 2009, 7:53pm UTC](https://www.ruby-forum.com/t/link-to-function-and-link-to-remote/176022/2 "2009-09-23T19:53:25Z")

</div>

Vlad,

I think you may want to check out the :with option for the  
link\_to\_remote. It will allow you to pass back to the controller the  
comment.id for the link that was clicked. Is that what you mean?

–Tom

On Sep 23, 1:03 pm, Vlad K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
