Using ERB in $() function ??


I am new to Ajax, and I was wondering if it is possible to have an id passed to a $() function in runtime.

Like I am generating id for an article at runtime doing something like id=article-<%= %>

Now id I want to have a toggle element on this id then can I do Element.toggle('$('article-<%= %>')', 'blind') as well..??.. I cannot use the "this" parameter

Thanks and regards Sanjay

If you mean runtime as in when the rjs is generated then yes: Element.toggle("$('article-#{ }')", 'blind') If you mean runtime as in when the user's browser executes the javascript then no.


Dosen't seem to work like that also. Can you suggest some other work-around

<p><%= link_to_function "Meta Information >>", "Element.toggle("$('meta- #{}')", 'blind')" %></p>

Thanks and regards

Frederick Cheung wrote:

Ok.'s working fine..just some syntax issues..thanks a lot again

Sanjay Bisht wrote: