포커스가 noteTitle로 설정되지 않는 이유는 무엇입니까?infoWindow에서 입력 필드에 포커스를 설정할 수 없습니다.
Google지도 API V3을 사용하고 있습니다.
getNoteForm()은 "noteTitle"입력 필드를 리턴합니다.
$ ("# noteTitle") .focus()는 방화 광에서 실행하면 잘 작동합니다.
나는지도를 클릭 할 때이 함수를 호출하면 이벤트 리스너를 추가하기 전에 정보창을 여는처럼
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);
});
});
}
}
다른 곳에 $ ("# noteTitle"). focus(); 문을 옮겨 보았습니까? 아마 $ (document) .ready로 시작해도 될까요? – HurnsMobile
예, 행운을 보냅니다. – thomas
이벤트가 올바르게 발생했는지 확인 했습니까? 'alert ('something');을 추가하여 실행 여부를 확인하십시오. –