2011-11-23 138 views
2

我想使用fcbk_autocomplete函數我從http://www.emposha.com/javascript/fcbkcomplete.html下載谷歌地圖infowindow在谷歌地圖中使用jQuery infowindow

本來我已經設置了一個infowindow內容如下圖所示

var friends = document.getElementsByTagName('option'), 
    res = ''; 

for (var i = 0; i < friends.length; i++) { 
    res = res + '<option value="'+friends[i].id+'">' + friends[i].value + '</option>'; 
} 

var contentString = '<form method="post" action="mapit.do">' 
    + '<textarea name="comment" cols="40" rows="5">Enter your gossips here...</textarea><br>' 
    + 'image url: <input type="text" cols="40" name="url"></input><br>' 
    + '<input type="hidden" name="position" value="' + event.latLng.toUrlValue() + '"/>' 
    + '<select id="select3" name="about">' + res + '</select>' 
    + '<input type="submit" value="Submit" />' 
    + '</form>'; 

options是我想從選擇數據的列表和它們存儲在一個看不見的分裂。

我打開信息窗口後,我試圖通過調用fcbkcomplete功能:

$("#select3").fcbkcomplete({ 
    addontab: true,     
    maxitems: 10, 
    input_min_size: 0, 
    height: 10, 
    cache: true, 
    newel: true, 
}); 

但它對select3部分沒有任何影響。我試圖撥打document.getElementById("select3"),它給了我空。我的問題是我可以在哪裏調用這個函數來確保它看到id爲select3的元素?

回答

0

這是很難模擬沒有谷歌地圖加載和一切,但我開始jsFiddle for you here

您嘗試使用的插件似乎在我的上下文中工作;但是,這可能無法解釋您在gmap info window中嘗試使用它的行爲。儘管如此,如果你想要的話,你可以添加你的gmap的東西到JavaScript源,我可以幫你從那裏調試。

+1

非常感謝你它的工作!我將div添加到了我的視圖中,然後使用了var layer = document.getElementById(「mock-infowindow」); \t \t \t變種信息窗口=新google.maps.InfoWindow({ \t \t \t \t內容:層 \t \t \t}); ,使其工作 –