Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 972435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:07:27+00:00 2026-05-16T03:07:27+00:00

I’m currently writing a Rails 3 app that uses the google maps API (v3)

  • 0

I’m currently writing a Rails 3 app that uses the google maps API (v3) extensively. Currently, the infowindow for each marker contains a link that takes the user to the page for that particular marker – ie. /places/1. A sample of my code is below:

jQuery.getJSON("/places", function(json) {
      if (json.length > 0) {
        for (i=0; i<json.length; i++) {
          var place = json[i];
          var category = json[i].tag;
          addLocation(place,category);
        }
      }
    });

    function addLocation(place,category) {
   var marker = new google.maps.Marker({

position: new google.maps.LatLng(place.lat, place.lng),
map: map,
title: place.name,
icon: image[place.tag]
});

      marker.mycategory = category;
      gmarkers.push(marker);

      google.maps.event.addListener(marker, 'click', function() {
        if (infowindow) infowindow.close();
        infowindow = new google.maps.InfoWindow({
          content: "<h3>"+ place.name +"</h3><p>" + place.tag +"</p><a href='/places/"+place.id+"'>Show more!</a>"
        });
        infowindow.open(map, marker);
});
 }

This all works fine so far, but I would like to eliminate the page refresh that occurs after the user clicks on the infowindow link by introducing an AJAX call. Is this possible? Any help would be much appreciated!

EDIT:

The .live function is require to target the infowindow link, as the infowindows are often created after the DOM is ready. So I can hit the link okay, but am struggling with how to update part of the page from my map.js file. I’ve got something like this at the moment:

jQuery('#place_link').live('click', function() {
  //alert("You clicked here.");
  jQuery('#place_details').load('/places/"+place.id" #place_details');
  return false;
});

…where #place_details contains the information about the marker I’d like to update with an AJAX call. As I mentioned above, the .live part works fine, as the alert appears when the link is clicked (when not commented out). How can I go about achieving this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:07:27+00:00Added an answer on May 16, 2026 at 3:07 am

    Solved, with plenty of help from this question. In my map.js file:

    jQuery(document).ready(function(){
      mapInit();
      jQuery('#place_link').live('click', function() {
        var url = jQuery(this).attr('href');
        jQuery.ajax({
          beforeSend: function(request) { request.setRequestHeader("Accept", "text/javascript"); },
          success: function(response) { jQuery('#place_details').empty().append(response); },
          type: 'get',
          url: url
        });
        return false;
      });
    });
    

    In my view:

    <div id="map" style="width: 100%; height: 500px;"></div>
    <form action="#">
      Attractions: <input type="checkbox" id="attractionbox"/> &nbsp;&nbsp;
      Food and Drink: <input type="checkbox" id="foodbox" /> &nbsp;&nbsp;
      Hotels: <input type="checkbox" id="hotelbox" /> &nbsp;&nbsp;
      Towns/Cities: <input type="checkbox" id="citybox" /><br />
    </form>
    
    <p id="notice"><%= notice %></p>
    
    <div id="place_details">
      <%= render 'placeshow' %> 
    </div>
    

    And in my controller:

    def show
      @place = Place.find(params[:id])
    
      respond_to do |format|
        format.html { render :action => "show" and return }
        format.json { render :json => @places.all }
        format.js { render :partial => "placeshow", :layout => false and return }
      end
    end
    

    It works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.