I have this code within a javascript function: function load(test) { var coordinates = new Array(); coordinates = <%= params[:coordinates] %> } the params contains an array with double digit numbers such as [24,45], but when it is converted within the javascript function, it turns into one long number, i.e. 2445. I found this by doing an alert() with the result. I don''t really know much about javascript, so Im not sure if this is an integer or a string or what, but ultimately I need to get these original two digit numbers separated and into a javascript array. I tried performing some javascript string operations but they do not seem to be working. Any one have any ideas here? Thanks, Dave --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
there are two functions: array_or_string_for_javascript options_for_javascript have a look at the source first one, it''s basically doing: "[''#{option.join(''\'',\'''')}'']" joining the array elements to a string --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 21, 8:22 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> there are two functions: > array_or_string_for_javascript > options_for_javascript > > have a look at the source first one, it''s basically doing: > "[''#{option.join(''\'',\'''')}'']" > > joining the array elements to a stringto_json would also work: <%= params[:coordinates].to_json %> --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
cool, yea array_or_string_for_javascript works well: var coordinates <%= array_or_string_for_javascript(params[:coordinates])%> On Sep 21, 5:22 am, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> there are two functions: > array_or_string_for_javascript > options_for_javascript > > have a look at the source first one, it''s basically doing: > "[''#{option.join(''\'',\'''')}'']" > > joining the array elements to a string--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---