How do I pass the ruby arrays to Js func and access it(from JS func)from
a view page.. In my view page
Hold up... Ruby doesn't have "view pages" by itself. Maybe you wanted:
http://groups.google.com/group/rubyonrails-talk
I'll try to answer anyway, but you haven't given a lot of information here.
I have defined an array as
<% asset.push({'url' => image['url'],
'height' => height_ser,
'width'=> width_ser
}) %>
I don't think that defines an array, and I'm not sure it belongs in view code
anyway. But where is 'asset' actually defined?
And I have passed this array as
<%= submit_tag "
Continue",:Onclick=>"insert_slide(#{asset['height'].to_json},
#{asset['width'].to_json)" %>
That's really not looking like an array. It's looking like you're accessing a
hash.
So now there's an even more important question: What is 'height_ser' and
'width_ser', and where are those defined? Do you really need to convert them
to json here?
But in the JS function(defined as function insert_slide(height, width))
of insert_slide I am not able to access this array of height and width
It is showing an error as asset_org is not defined... Any inputs on
this??
What's asset_org? You never mentioned it before this.
Wherever you end up asking your question, you probably want to provide a LOT
more detail. Paste the actual error, and if it's a stacktrace, you may want to
paste at least a few more lines of it than you think you need, if not the
entire trace.
···
On Wednesday, July 13, 2011 03:40:10 PM ruby rails wrote: