hello, i''m a newbie using ROR. i have this function below inside my public/application.js and i''m wondering whether i can replace "San Fransisco" and "New York" in this command "setDirections("San Francisco", "New York", "en_US");" with session[:address1] and session[:address2]....??? Please can anyone show me how to do it... " function initialize() { if (GBrowserIsCompatible()) { alert("kyaaaaaaaa") map = new GMap2(document.getElementById("map_canvas")); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "load", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); setDirections("San Francisco", "New York", "en_US"); } } " --~--~---------~--~----~------------~-------~--~----~ 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 Fri, Apr 11, 2008 at 3:13 PM, Adi <g0053.82-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hello, i''m a newbie using ROR. > i have this function below inside my public/application.js and i''m > wondering whether i can replace "San Fransisco" and "New York" in this > command "setDirections("San Francisco", "New York", "en_US");" with > session[:address1] and session[:address2]....??? > Please can anyone show me how to do it...One way (not the DRYest or most maintainable, but definately the simplest and it will get you going) is in your view.html.erb file you can put: <% if session[:address1] -%> <script type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { alert("kyaaaaaaaa") map = new GMap2(document.getElementById("map_canvas")); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "load", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); setDirections("<%= session[:address1] -%>", "<%session[:address2] -%>", "en_US"); } } </script> <% end -%> And then take it out of application.js Regards Mikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks a lot Mikel... But now i really can''t try whether it''s working or not... I think there''s something wrong with my internet connection now... after i see you code, i''m wondering, if it''s possible to write the code inside the application.js file like this code below : " function initialize() { if (GBrowserIsCompatible()) { alert("kyaaaaaaaa") map = new GMap2(document.getElementById("map_canvas")); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "load", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); setDirections(<%= session[:address1] -%>, <%= session[:address2] -%>, "en_US"); } } " Regards Adi --~--~---------~--~----~------------~-------~--~----~ 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 11 Apr 2008, at 08:45, Adi wrote:> > Thanks a lot Mikel... But now i really can''t try whether it''s working > or not... I think there''s something wrong with my internet connection > now... after i see you code, i''m wondering, if it''s possible to write > the code inside the application.js file like this code below : > " > function initialize() { > if (GBrowserIsCompatible()) { > alert("kyaaaaaaaa") > > map = new GMap2(document.getElementById("map_canvas")); > gdir = new GDirections(map, > document.getElementById("directions")); > GEvent.addListener(gdir, "load", onGDirectionsLoad); > GEvent.addListener(gdir, "error", handleErrors); > setDirections(<%= session[:address1] -%>, <%= session[:address2] -%>, > "en_US"); > } > } > " >application.js isn''t passed through erb, so no. If I were you I''d make that initialize function take the 2 addresses as its arguments and call it from somewhere where you do have access to the session. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the information Fred, i''m just confused from where i can access the session...?? I still can''t try the Mikel''s solution, cause i think there are troubles with my internet connection... Regards, Adi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mikel, I''ve tried what you suggested me to do. And the result is i got an unknown error. After a few trial, i know that if i replace "setDirections("<%= session[:address1] -%>", "<%= session[:address2] - %>", "en_US");" with fixed command such as "setDirections("new york", "boston", "en_US");" then the error will never showed up... In my opinion, the setDirections function, somehow did not passing the right parameters... If you don''t mind, would you share me any opinion... Regards, Adi --~--~---------~--~----~------------~-------~--~----~ 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 Mon, Apr 14, 2008 at 12:48 PM, Adi <g0053.82-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Mikel, I''ve tried what you suggested me to do. And the result is i got > an unknown error. After a few trial, i know that if i replace > "setDirections("<%= session[:address1] -%>", "<%= session[:address2] - > %>", "en_US");" with fixed command such as "setDirections("new york", > "boston", "en_US");" then the error will never showed up... In my > opinion, the setDirections function, somehow did not passing the right > parameters...Where did you put that javascript? In the view template? Or in application.js? Mikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
i put only initialize function in the view template and the other function i put them in application.js... Adi --~--~---------~--~----~------------~-------~--~----~ 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 Mon, Apr 14, 2008 at 7:33 PM, Adi <g0053.82-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i put only initialize function in the view template and the other > function i put them in application.js...Well, the <%= -%> parts _have_ to be in your view template. They can _not_ be in the application.js. The <%= -%> contains ruby code that will only get executed if it is in an ERB template. Regards Mikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---