# Pass variable to RJS

**URL:** <https://www.ruby-forum.com/t/pass-variable-to-rjs/171283>\
**Category:** Rails\
**Created:** [June 30, 2009, 1:06am UTC](https://www.ruby-forum.com/t/pass-variable-to-rjs/171283 "2009-06-30T01:06:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trib4lmaniac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9de053/32.png) [@trib4lmaniac](https://www.ruby-forum.com/u/trib4lmaniac)\
**Post date:** [June 30, 2009, 1:06am UTC](https://www.ruby-forum.com/t/pass-variable-to-rjs/171283/1 "2009-06-30T01:06:24Z")

</div>

Ok, so, ive got a link and a rjs file, is there a way i can pass a  
variable to the rjs by the remote\_to link

example…

\<%= link\_to\_remote “All”, :url =\> ‘all’ %\>  
\<%= link\_to\_remote “Messages”, :url =\> ‘messages’ %\>  
\<%= link\_to\_remote “Requests”, :url =\> ‘requests’ %\>  
\<%= link\_to\_remote “Comments”, :url =\> ‘comments’ %\>

instead of having a rjs for each one performing the action below,  
could i have one and pass a variable to it so it knowns with partial  
to render.

my rjs is…

page.visual\_effect :fade, “activity”, :queue =\> ‘front’, :duration =\>  
0.2  
page.delay(0.3) do  
page.replace\_html “activity”, :partial =\> “all”  
end  
page.delay(0.5) do  
page.visual\_effect :appear, “activity”, :duration =\> 0.6  
end

any ideas?

Thanxs from a newbie
