Topic: How to call a rails method from javascript (googlemaps)

My googlemap app allows users to add points by clicking on map and bringing up an info box with  SAVE / DELETE options.  On SAVE I'd like to call my existing Rails action that ajax updates a div on the page with a new line with some info about the location selected.
Problem is I can't figure out how to call the Rails action from the javascript function.  Any advice on calling rails actions from javascript would be appreciated.   

Javascript and Rails code

Javascript function to SAVE selected point: 

function tripWaypointSave(m){
    for (x in allmarkers)
        if (allmarkers[x].get("MarkerID") == m)
            allmarkers[x].set("DelFlag", "N");
            for (y in allinfo)
                //Close the corresponding info window
                if (allinfo[y].get("MarkerID") == m)
                    allinfo[y].set("DelFlag", "N");
                                // Correct info box now closed BUT HOW TO CALL THE RAILS ACTION?
                                //    remote_function(:url => { :action => "add_to_trip"} );

Rails action (for test purposes this is presently just a button that uses ajax to add a new line to the page without refreshing the map).

<% form_remote_tag :url => {:action => "add_to_trip"} do %>
    <%= submit_tag "Add to Trip 2"%>
<% end %>

Last edited by petetodd (2010-07-04 12:29:25)