Cannot set focus on input field in infoWindow
- by thomas
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);
});
});
}
}