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?

Do you have a @thing available to your template??

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.

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

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