I am having trouble sending a local variable to a partial. When I call
it from the main program it works, but when I try to do so from a rjs
file, it wont work.
In my main code I have
<% for each name in @list %>
<%= render_partial ''/printName'', name.id %>
<% end %>
Then in the _printName.rhtml file its simply
<%= "
<div class="names" id="name_#{printName}">
#{ link_to_remote("test",
:url => {:action => "didItWork",
:id => printName,
:update => ''name_#{printName}''}
}
<br></div>
"%>
Then in the rjs file
if !@name.nil?
page.replace_html "name_#{@name.id}", render_partial
''printName'',
@name.id
end
which does not work. Previously I had this working by skipping the
partial and printing the html code within the rjs file, but that
violates DRY
if !@name.nil?
page.replace_html "name_#{@name}",
"
<div class="names" id="name_#{@name}">
#{ link_to_remote("test",
:url => {:action => "didItWork",
:id => @name,
:update => ''name_#{@name}''}
}
<br></div>
"
end
Any advice on how to send the variable in the rjs file?
--
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
-~----------~----~----~----~------~----~------~--~---