How to send parameters to rjs

How do I pass variables into an rjs?

I’d like to do:

page.replace_html “frame_set_<>”, :partial => ‘list_frame_set’


<%= 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]

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.

page.replace_html :dom_id, :partial => ‘list_frame_set’, :locals => {
:dom_id => “frame_set_#{}” }

Doesn’t work either.

Jonathan D.

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

I added:
@dom_id = “frame_set_#{}”
to the controller. Then I changed the rjs to:
page.replace_html @dom_id, :partial => ‘list_frame_set’

Jonathan D. wrote:

page.replace_html “frame_set_#{}”, :partial => ‘list_frame_set’

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

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

Satish N Kota

On May 12, 2:28 am, Jonathan D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs