I have a java script function which I want to call once the page has loaded.
Initially it looked like this: <body onload="doStuff();"> I was then advised by people on this forum that it is good practice to put this into an external js file thus: document.observe('dom:loaded', function() { doStuff(); }); That also worked fine. Now, I want to pass a variable to this function which is generated in my application's controller (@member) If I do this in my view, everything works fine: <body onload="doStuff(<%= @member %>);"> Yet if I do this in the js file, then nothing works (as might be expected). document.observe('dom:loaded', function() { doStuff(@member); }); Is there any way to use 'document.observe' in an external js file with a variable generated in my ruby controller? If not, what is the best practice in this case? Thanks in advance -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---