Hi - I''m having a bit of trouble with my application. I have this view
that calls a javascript function "zip_map". I want to pass to it a
scalar array "@zip_geo" but I don''t know how to pass an array
to a
javascript function in rails. This is what the code looks like:
THE .rhtml file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" language="Javascript"
src="init_demo_report.js">
</script>
</head>
<body onload="zip_map(<%= @zip_geo %>)"
onunload="GUnload()">
....
....
....
</body>
</html>
THE FILE "init_demo_report.js" contains this code:
function zip_map(zip_geo) {
....
....
....
}
Any help will be appreciated, thank you.
--
Posted via http://www.ruby-forum.com/.
Mark Reginald James
2006-Aug-17 06:15 UTC
[Rails] Re: How to pass an array to a javascript function.
Ras Ras wrote:> Hi - I''m having a bit of trouble with my application. I have this view > that calls a javascript function "zip_map". I want to pass to it a > scalar array "@zip_geo" but I don''t know how to pass an array to a > javascript function in rails. This is what the code looks like: > ... > <body onload="zip_map(<%= @zip_geo %>)" onunload="GUnload()">Either @zip_geo.to_json or @zip_geo.inspect -- We develop, watch us RoR, in numbers too big to ignore.