# How to send parameters to rjs

**URL:** <https://www.ruby-forum.com/t/how-to-send-parameters-to-rjs/103961>\
**Category:** Rails\
**Created:** [May 11, 2007, 11:28pm UTC](https://www.ruby-forum.com/t/how-to-send-parameters-to-rjs/103961 "2007-05-11T23:28:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonathan](https://www.ruby-forum.com/u/jonathan)\
**Post date:** [May 11, 2007, 11:28pm UTC](https://www.ruby-forum.com/t/how-to-send-parameters-to-rjs/103961/1 "2007-05-11T23:28:48Z")

</div>

How do I pass variables into an rjs?

I’d like to do:

page.replace\_html “frame\_set\_\<%=job.id%\>”, :partial =\> ‘list\_frame\_set’

where

\<%= link\_to\_remote “Display Frame Sets”, :url =\> {:action =\>  
:toggle\_frame\_set, :id =\> job} %\>

is in the view and

def toggle\_frame\_set  
@job = Job.find\_by\_id params[:id]  
end

is in the controller.

@job is passed to the partial, and it works fine if I hard code in an id  
in the rjs, I just need some way to pass the id to the javascript.

---

<div class="post-metadata">

**Author:** ![jonathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonathan](https://www.ruby-forum.com/u/jonathan)\
**Post date:** [May 11, 2007, 11:40pm UTC](https://www.ruby-forum.com/t/how-to-send-parameters-to-rjs/103961/2 "2007-05-11T23:40:52Z")

</div>

page.replace\_html :dom\_id, :partial =\> ‘list\_frame\_set’, :locals =\> {  
:dom\_id =\> “frame\_set\_#{@job.id}” }

Doesn’t work either.

Jonathan D.

---

<div class="post-metadata">

**Author:** ![jonathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonathan](https://www.ruby-forum.com/u/jonathan)\
**Post date:** [May 11, 2007, 11:51pm UTC](https://www.ruby-forum.com/t/how-to-send-parameters-to-rjs/103961/3 "2007-05-11T23:51:10Z")

</div>

Hmm… I figured out something that worked, but I still think that some  
other way should work.

I added:  
@dom\_id = “frame\_set\_#{@job.id}”  
to the controller. Then I changed the rjs to:  
page.replace\_html @dom\_id, :partial =\> ‘list\_frame\_set’

---

<div class="post-metadata">

**Author:** ![jonathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonathan](https://www.ruby-forum.com/u/jonathan)\
**Post date:** [May 12, 2007, 12:48am UTC](https://www.ruby-forum.com/t/how-to-send-parameters-to-rjs/103961/4 "2007-05-12T00:48:38Z")

</div>

Jonathan D. wrote:

> 

page.replace\_html “frame\_set\_#{job.id}”, :partial =\> ‘list\_frame\_set’

have you tried that? or #{@job} make sure it’s in double quotation marks

---

<div class="post-metadata">

**Author:** ![jonathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonathan](https://www.ruby-forum.com/u/jonathan)\
**Post date:** [May 12, 2007, 11:46am UTC](https://www.ruby-forum.com/t/how-to-send-parameters-to-rjs/103961/5 "2007-05-12T11:46:15Z")

</div>

Hi Jonathan,

use the below options

\<%= link\_to\_remote “Display Frame Sets”, :url =\> {:action =\>  
:toggle\_frame\_set, :locals=\>{:job =\> @job}} %\>

insted of

> \<%= link\_to\_remote “Display Frame Sets”, :url =\> {:action =\>  
> :toggle\_frame\_set, :id =\> job} %\>

hope this works

Regards  
Satish N Kota  
[www.heurionconsulting.com](http://www.heurionconsulting.com)

On May 12, 2:28 am, Jonathan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
