Instance variables in Javascript param


#1

How can I make this work ?

@div_id is an instance variable ?

TIA


#2

nuubie wrote:

How can I make this work ?

@div_id is an instance variable ?

TIA

The @div_id needs to be encapsulated in <%= %> tags in order to be
parsed by ruby. i.e.

It is probably preferable to use the built-in rails helpers for this
though. Try:
<%= link_to_function ‘Link text’, visual_effect(:fade, @div_id) %>

-Sam


#3

or use the tag helper:

<%= content_tag “a”, “link-text”, {:href => “#”, :onclick => “new
Effect.Fade(#{div_id})”} %>


#4

another possible one:

link_to(“link-text”, {}, {:onclick => “new Effect.Fade(#{div_id})”} )

[did not test that…]


#5

Wow, this is a great list.

Real-time response…

Thanks a lot, guys.
Peter E. wrote:

another possible one:

link_to(“link-text”, {}, {:onclick => “new Effect.Fade(#{div_id})”} )

[did not test that…]