Syntax problem or something else?

Hi, I’m pretty sure this is a simple problem but I can’t seem to work it
out.
I have a series of news stories and I would like the body of the story
to be displayed (using a visual_effect toggle) when the user clicks on
the title.

The toggle works ok, but it does not matter which title I click on, only
the first story is ever displayed.

Can anyone see what is the problem?
Thanks

Latest News

<% for newsitem in @newsitems %>

<%= link_to newsitem.title, "#", :onclick => visual_effect(:toggle_appear, ('newsitem.id'), :duration => 0.5) %>

<%= newsitem.created_at.strftime('%a %d %b %Y, %I:%M%p') %> by <%= newsitem.user.login %>

<%= newsitem.body %>

<% end %>

Try replacing
visual_effect(:toggle_appear, (‘newsitem.id’), :duration => 0.5) with
visual_effect(:toggle_appear, “#{newsitem.id}”, :duration => 0.5)

and

with

The way you have it is the literal string ‘newsitem.id’.
“#{newsitem.id}” and <%= newsitem.id %> should resolve to what you
want, the id of the item.

On Aug 26, 2:06 pm, Dan S. [email protected]

On Aug 26, 9:06 pm, Dan S. [email protected]
wrote:

Hi, I’m pretty sure this is a simple problem but I can’t seem to work it
out.
I have a series of news stories and I would like the body of the story
to be displayed (using a visual_effect toggle) when the user clicks on
the title.

The toggle works ok, but it does not matter which title I click on, only
the first story is ever displayed.

Your problem (which you should be able to see if you looked at the
html) is that all of your divs have as id the string newsitem.id.
When you write (‘newsitem.id’) (not sure what you were trying to
accomplish with the parentheses no interpolation is taking place,
that’s just a string literal.
if you want interpolation then you need to use double quotes and #{}
to indicate what should be interpolated, eg "my name is #{ name } "

Fred