Accessing rails variables in javascript

Hi-
How to access class variables (@something) within onLoad javascript
functions?

I pass an array of customers object to a .rhtml file. When it is
rendered on the browser, I call an onLoad function. I need to access the
@customers objects array in my onLoad function. How can I do that. For
example, I need to get to @customers[0][:customer_name] - how to do
that? thanks

Thila Thila wrote:

Hi-
How to access class variables (@something) within onLoad javascript
functions?

I pass an array of customers object to a .rhtml file. When it is
rendered on the browser, I call an onLoad function. I need to access the
@customers objects array in my onLoad function. How can I do that. For
example, I need to get to @customers[0][:customer_name] - how to do
that? thanks

Try something like this in your .rhtml

Then access some_var from onLoad.

Topher

Your only other option would be able to use AJAX to grab the ruby var
from the server.

Tim

var js_var = <%= @ruby_var %>;

On Aug 28 2006, 12:00 am, Thila Thila <rails-mailing-l…@andreas-