[Ruby] evaluating Javascript within <%= %> within a template file
Frank Schwieterman
fschwiet at gmail.com
Mon Aug 6 13:35:34 PDT 2007
I'm in a situation where I have some Javascript and am using <%= url_for()
%> to generate a value within the JavaScript. One of the parameters for
url_for however is coming from a Javascript variable, I'm not sure how to do
it. I've written the below function trying to imitate my problem- variable
"id_to_use" is not valid within an <%= ... %> enclosure.
function whats_the_url(id_to_use)
{
var url = <%= url_for(:action=> 'edit', :id => id_to_use) %>;
return url;
}
More information about the Ruby
mailing list