Cannot set focus on input field in infoWindow

Posted by thomas on Stack Overflow See other posts from Stack Overflow or by thomas
Published on 2010-06-14T15:44:19Z Indexed on 2010/06/14 17:02 UTC
Read the original article Hit count: 261

Filed under:
|

Hi

Why is focus not set to noteTitle?

I am using google maps API V3.

The getNoteForm() returns a input field "noteTitle".

The $("#noteTitle").focus() works fine when executed in firebug.

I call this function when clicking on the map:

function setNewNoteInfowindow(latlng) {
 if (geocoder) {
       geocoder.geocode({'latLng': latlng}, function(results, status) {
   var address = "";

     if (status == google.maps.GeocoderStatus.OK) {
    if (results[1]) { 
     address =  results[1].formatted_address;
            }
         }

   newNoteInfowindow = new google.maps.InfoWindow({
    content: getNoteForm(latlng, address),
       size: new google.maps.Size(40,50)
   });

   newNoteInfowindow.open(map, newNoteMarker);

   google.maps.event.addListener(newNoteInfowindow, 'domready', function() {
          $("#noteTitle").focus();
      });

   google.maps.event.addListener(newNoteInfowindow, 'closeclick', function() {
          newNoteMarker.setVisible(false);
      });
  });
 }
}

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about google-maps