title: Google Maps infowindow.setContent as a DOM element with jQuery seems only works once?
body: <p>I'm getting very frustrated and I'm hoping someone here can help. I have a maps app where there are several markers on the maps with infoWindows whose content updates regularly. My solution has been to place the divs that will go into the infoWindow in the DOM in a hidden container that can be updated by my updater code in the background. Then I use a single infoWindow and just set the content to the DOM element using query:</p>
  
  <pre><code>google.maps.event.addListener(marker, 'click', function(){
       infoWindow.setContent($(#"+id+"-window-content)[0]);
       infoWindow.open(map, marker);
  }
  </code></pre>
  
  <p>The thing works great... once. Then it won't open again for that maker. I have noticed that if I open the window on one marker (Marker A), and then close it, and then open it on another maker (Marker B), and then go back to the Marker A, the window will appear beside Marker A, but with Marker B's content.</p>
  
  <p>Why won't my script set the content to the DOM element a second time... It's almost like using the jQuery selector is deleting the element from the DOM.</p>
  
  <p>Cheers,</p>
  
  <p>whiteatom</p>
  
  <hr>
  
  <p>Hello again,</p>
  
  <p>Turns out I may have answered my own question when I was trying to explain it here.</p>
  
  <p>Passing a DOM element to the setContent() function seems to actually remove it from the DOM and put it in the infoWindow, so the next time I try and grab it, it's no longer there. My fix was to add a clone() to the jQuery call and it seems to work now.</p>
  
  <pre><code>google.maps.event.addListener(marker, 'click', function(){
       infoWindow.setContent($(#"+id+"-window-content).clone()[0]);
       infoWindow.open(map, marker);
  }
  </code></pre>
  
  <p>Can anyone confirm this is the behaviour of the setContent when a DOM element is passed to it? is this the best way to handle this?</p>
  
  <p>Cheers,</p>
  
  <p>whiteatom</p>