Forum: Ruby on Rails How to send parameters to rjs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
44a7552ad0319082b80f27fc3397b52e?d=identicon&s=25 Jonathan Dobbie (Guest)
on 2007-05-11 23:28
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.
44a7552ad0319082b80f27fc3397b52e?d=identicon&s=25 Jonathan Dobbie (Guest)
on 2007-05-11 23:40
page.replace_html :dom_id, :partial => 'list_frame_set', :locals => {
:dom_id => "frame_set_#{@job.id}" }

Doesn't work either.

Jonathan Dobbie
44a7552ad0319082b80f27fc3397b52e?d=identicon&s=25 Jonathan Dobbie (Guest)
on 2007-05-11 23:51
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'
3b15a36c3ac77a31f3296d04bbe0d408?d=identicon&s=25 Vincent Franco (Guest)
on 2007-05-12 00:48
(Received via mailing list)
Jonathan Dobbie 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
Cdc8ad5e02b00820a7336ed80b5ad554?d=identicon&s=25 satishnkota@googlemail.com (Guest)
on 2007-05-12 11:46
(Received via mailing list)
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


On May 12, 2:28 am, Jonathan Dobbie <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.