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.
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
page.replace_html :dom_id, :partial => ''list_frame_set'',
:locals => {
:dom_id => "frame_set_#{@job.id}" }
Doesn''t work either.
Jonathan Dobbie
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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''
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Jonathan Dobbie wrote:> 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. > >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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
satishnkota-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-May-12  09:44 UTC
Re: How to send parameters to rjs
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...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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.
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---