[Ruby] evaluating Javascript within <%= %> within a template file
Jack Danger Canty
seattle.rb at 6brand.com
Mon Aug 6 13:51:28 PDT 2007
You want this:
function whats_the_url(id_to_use)
{
var url = '<%= url_for(:action=> 'edit', :id => "'+id_to_use+'") %>';
return url;
}
::Jack Danger Canty
On 8/6/07, Frank Schwieterman <fschwiet at gmail.com> wrote:
>
> 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;
> }
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>
More information about the Ruby
mailing list