爲什麼焦點未設置爲noteTitle?無法在infoWindow中的輸入字段上設置焦點
我正在使用谷歌地圖API V3。
getNoteForm()返回一個輸入字段「noteTitle」。
$(「#noteTitle」)。focus()在firebug中執行時工作正常。
我在地圖上點擊時調用這個函數:
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 2010-06-14 16:31:48
是的,但運氣好的話...... – thomas 2010-06-14 16:39:22
您是否驗證了該事件是否正確啓動?添加一個alert('something');'看看它是否執行.. – 2010-06-14 17:27:08