# Javascript + rails

**URL:** <https://www.ruby-forum.com/t/javascript-rails/105968>\
**Category:** Rails\
**Created:** [June 5, 2007, 2:52am UTC](https://www.ruby-forum.com/t/javascript-rails/105968 "2007-06-05T02:52:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpacheco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/dfb087/32.png) [@hpacheco](https://www.ruby-forum.com/u/hpacheco)\
**Post date:** [June 5, 2007, 2:52am UTC](https://www.ruby-forum.com/t/javascript-rails/105968/1 "2007-06-05T02:52:24Z")

</div>

Hi,

I have the following code for a google map event:

@map.event\_init(@map,:click,“function(overlay,point)  
{  
if (overlay)  
{  
map.removeOverlay(overlay);  
document.getElementById(“latitude”).value=null;  
document.getElementById(“longitude”).value=null;  
}  
else  
{  
map.addOverlay(new GMarker(point));  
document.getElementById(“latitude”).value=point.y;  
document.getElementById(“longitude”).value=point.x;  
}  
}”)

As you can see, the action is written in JS.  
How can I call a ruby action from that code, so I can handle events  
properly?

Thanks,  
hugo
