I'd like to know how can I get the ID field from my Model to pass in the JavaScript that I call when I click in a marker.
My model:
acts_as_gmappable :process_geocoding => false, :lat => "lat", :lng => "lon"
My controller
def index
@locales_markers = Locale.all.to_gmaps4rails
respond_to do |format|
format.html { render :layout => false }
end
end
My View
<%= gmaps("markers" => { "data" => @locales_markers } %>
<% content_for :scripts do %>
<script>
Gmaps4Rails.callback = function() {
for (var i = 0; i < this.markers.length; ++i) {
google.maps.event.addListener(Gmaps4Rails.markers[i].serviceObject, 'click', function(){
$('#info').load('/messages/' **<HERE I'D LIKE TO PASS THE ID>**);
$('#info').dialog("open");
});
}
};
</script>
<% end %>
Thanks, Luciano