Hi, I am using the MapQuest API and I would like to set the name for the location by using MQLocation.setName("name") ... I have the name in the Order class, order.name ... how can I combine the ruby code in the javascript ?? so something like MQLocation.setName( order.name ) ... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Swaraj Shergill
2007-Jan-13 16:30 UTC
Newbie question on using javascript within rails view
Hi, I am using the MapQuest API and I would like to set the name for the location by using MQLocation.setName(name) ... I have the name in a Order class, and an object order... how can I combine the ruby code with the javascript ?? <h2><%= order.id %></h2> <div id=''myMap'' class=''myMap'' style="height:400;width:400"> </div> <script src="http://web.openapi.mapquest.com/oapi/transaction?request=script&key=mjtd%7Clu6z200rn9%2Cas%3Do5-dr8gh" type="text/javascript"></script> <script type="text/javascript"> var mq = new MQMap("myMap"); var loc1 = new MQLocation(); loc1.setName("test"); ....................... so for loc1 I''d like to set the name to order.name ... how can I do this ?? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
loc1.setName("<%= order.name %>"); Make sure you include the quotes. Depending on what possible characters can appear in order.name, you may also need to escape the text, using the "escape_javascript" helper method: loc1.setName("<%= escape_javascript order.name %>"); -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Swaraj Shergill
2007-Jan-13 17:17 UTC
Re: Newbie question on using javascript within rails view
Snow Man wrote:> loc1.setName("<%= order.name %>"); > > Make sure you include the quotes. > > Depending on what possible characters can appear in order.name, you may > also need to escape the text, using the "escape_javascript" helper > method: > > loc1.setName("<%= escape_javascript order.name %>");Thanks a lot !! that worked :) ... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---