Forum: Ruby on Rails Expanding javascript before sending it

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mickael F. (Guest)
on 2006-05-27 01:58
(Received via mailing list)

I had a simple javascript function directly in the rhtml with a rails
helper in it.
Before the page was sent to the client the rails help was of course

Moving it into a separated .js file, the rails code is, once again of
course,  no more expanded.

function save(id) {
   var el = document.getElementById('s'+id);
   el.src = "<%= theme_image_path('loading.gif')%>"
   new Ajax.Request('/task/save/'+id, {asynchronous:true,
   return false;

<%= theme_image_path('loading.gif')%> is not more expanded into pure
html once it is in a .js file.

Is there a way to generate the code before sending the js file to the
client ?
Or is there another way of doing rails code into js ?

Thanks for your help,
This topic is locked and can not be replied to.