Hi guys! In Rails, can you stick Rails code in a javascript function? An example, this code from the Geokit plugin on a view page which doesnt work for me: function initialize() { var map = new GMap(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.centerAndZoom(new GPoint(-122.443882, 37.769079), 5); <%@places.each do |place|%> var point = new GPoint(<%=place[:longitude]%>,<%=place[:latitude]%>); var marker = createMarker(point,''<div><%=h place[:description]%></div>'') map.addOverlay(marker); <%end%> } Any help would be appreciated! cheers! -- 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 -~----------~----~----~----~------~----~------~--~---
Hi guys! In Rails, can you stick Rails code in a javascript function? An example, this code from the Geokit plugin on a view page which doesnt work for me: <script> function initialize() { var map = new GMap(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.centerAndZoom(new GPoint(-122.443882, 37.769079), 5); <%@places.each do |place|%> var point = new GPoint(<%=place[:longitude]%>,<%=place[:latitude]%>); var marker = createMarker(point,''<div><%=h place[:description]%></div>'') map.addOverlay(marker); <%end%> } </script> Any help would be appreciated! cheers! -- 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 -~----------~----~----~----~------~----~------~--~---
you can put everything in a textfile with erb <% ... %> will be executed <%= ... %> will be executed and the return value inserted in the file so the above code looks fine and you should give us some details what ''does not work'' for you. get an error message? nothing happens at all? the erb tags are inserted ''as is'' in the output (check source code in browser)? -- 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 -~----------~----~----~----~------~----~------~--~---