Hi Ichiro, On Fri, 2010-01-15 at 19:38 +0100, Ichiro Saga wrote: > Hi, everyone. Is it possible to pass a local variable to a javascript > function? I have a javascript function in application.js, and try to > pass a local variable to the function in index.html.erb. If I passed a > string like 'the string', it worked fine. But when I passed a local > variable, the function didn't run. The function works fine except the > fact that it can't recognize the local variable. Any hint would be > appreciated. > Thanks in advance.
If the local variable is a simple object like a number or a string, just pass its value, not the object itself, using the .to_s method. If it's a more complex object, you'll want to convert it to a json object and pass that. HTH, Bill
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

