title: Preserving Nodes with Google InfoWindow and content_changed?
body: <p>I'm trying to use Google Maps's InfoWindow with DOM nodes and preserve the nodes between InfoWindow swaps without having to create an explicit content store outside of the DOM. Unfortunately, when an InfoWindow's content is changed the previous content seems to be destroyed, this is unfortunate as it makes it impossible to switch back to the previous node. To make matters worse, it appears that the InfoWindow's <code>content_changed</code> event has no reference to the previous content, as the MVC events have no <code>event</code> args. Furthermore, as mentioned <a href="http://code.google.com/apis/maps/documentation/javascript/events.html#EventProperties" rel="nofollow">here</a>, referencing the content property within the function references only the current value, and not the previous value, thus it would seem the previous value is gone for all tense and purposes. </p>
  
  <p>For example, say you wanted to do this, assume we already have a map, and LatLng in myLatLng, myLatLng2. Note the only reference to shortlived node was added to the dom.</p>
  
  <pre><code>
  document.body.appendChild(document.createElement('div')).id = 'shortlived';
  document.getElementById('shortlived').innerHTML = 'I will pass soon...';
  
  var infowindow = new google.maps.InfoWindow();
  var marker1 = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title:"Marker1"
  });
  var marker2 = new google.maps.Marker({
      position: myLatlng2,
      map: map,
      title:"Marker2"
  });
  
  google.maps.event.addListener(marker1, 'click', function() {
    infoWindow.setContent(document.getElementById('shortlived'));
    infowindow.open(map, marker1);
  });
  google.maps.event.addListener(marker2, 'click', function() {
    infoWindow.setContent('Some Text');
    infowindow.open(map, marker2);
  });
  </code></pre>
  
  <p>You'll notice that if you click on marker1 you see the shortlived node, then if you click on marker2 it goes away, but when you click marker1 again, you won't get shortlived, you may get 'Some Text' or you may get nothing, but in either case, shortlived is gone. In my case I would like to ideally do the following: </p>
  
  <pre><code>
  google.maps.event.addListener(infoWindow, 'content_changed' function(e){
      //where e.content is the previous content
      document.body.appendChild(e.content)
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>
  google.maps.event.addListener(infoWindow, 'content_changed' function(e){
      //No such thing exists
      document.body.appendChild(infoWindow.previousContent)
  }
  </code></pre>
  
  <p>This doesn't seem like it's possible out of the box, any ideas? Again, I would like to avoid creating an independent store to keep a separate reference to the DOM nodes, other than the reference already in the DOM. I'm hoping there's something I'm missing.</p>
  
  <p>Thanks in advance.</p>