How to pass an array to a javascript function

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:

.... .... ....

THE FILE “init_demo_report.js” contains this code:

function zip_map(zip_geo) {



}

Any help will be appreciated, thank you.

Ras R. 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:

Either @zip_geo.to_json or @zip_geo.inspect


We develop, watch us RoR, in numbers too big to ignore.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs