Due to the use of partials, I''m trying to dynamically generate the ids
being affected in an rjs template, but I can''t seem to get the syntax
to
work. Basically, I need to do the equivalent of this from the .rhtml
template:
page.show ''mything<%= @thing.id %>''
No joy there. Apparently RJS templates don''t work with embedded ruby.
So
I tried:
page.show ''mything'' + @thing.id
and
page.show ''mything#{@thing.id}''
and several other variations with no luck. I''m obviously grasping at
straws here. Any suggestions on how to get this to work?
--
Posted via http://www.ruby-forum.com/.
Do you have a @thing available to your template?? Ryan Williams wrote:>Due to the use of partials, I''m trying to dynamically generate the ids >being affected in an rjs template, but I can''t seem to get the syntax to >work. Basically, I need to do the equivalent of this from the .rhtml >template: > >page.show ''mything<%= @thing.id %>'' > >No joy there. Apparently RJS templates don''t work with embedded ruby. So >I tried: > >page.show ''mything'' + @thing.id > >and > >page.show ''mything#{@thing.id}'' > >and several other variations with no luck. I''m obviously grasping at >straws here. Any suggestions on how to get this to work? > > >
Can you post the code for your action? @thing won''t be available in
your RJS
template unless it''s set somewhere.
The last one wouldn''t be working in any case because you''re
using single
quotes instead of double quotes, so the method''s value isn''t
going to be
interpolated.
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Ryan Williams
Sent: Monday, June 26, 2006 10:48 AM
To: rails@lists.rubyonrails.org
Subject: [Rails] RJS Templates with dynamic id names
Due to the use of partials, I''m trying to dynamically generate the ids
being affected in an rjs template, but I can''t seem to get the syntax
to
work. Basically, I need to do the equivalent of this from the .rhtml
template:
page.show ''mything<%= @thing.id %>''
No joy there. Apparently RJS templates don''t work with embedded ruby.
So
I tried:
page.show ''mything'' + @thing.id
and
page.show ''mything#{@thing.id}''
and several other variations with no luck. I''m obviously grasping at
straws here. Any suggestions on how to get this to work?
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
> The last one wouldn''t be working in any case because you''re using single > quotes instead of double quotes, so the method''s value isn''t going to be > interpolated.Right you are. This worked: page.show "mything#{@thing.id}" Thanks! Ryan -- Posted via http://www.ruby-forum.com/.