Forum: Ruby on Rails Expanding javascript before sending it

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

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
expanded.

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,
evalScripts:true,
onComplete:function(request){eval(request.responseText)},
parameters:Form.serialize('tr'+id)});
   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,
Mickael.
This topic is locked and can not be replied to.