我想使用从http://www.emposha.com/javascript/fcbkcomplete.html下载的fcbk_autocomplete
函数在 Google map 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")
但它给了我 null。我的问题是我在哪里可以调用这个函数来确保它看到 id select3 的元素?
最佳答案
如果没有加载谷歌地图和一切,就很难模拟,但我开始了 jsFiddle for you here 。
您尝试使用的插件似乎在我的上下文中工作;但是,这可能无法解释您在尝试在 gmap 信息窗口
中使用它时所目睹的行为。不过,如果您愿意,可以将您的 gmap
内容添加到 javascript 源代码中,我可以帮助您从那里进行调试。
关于jquery - 在 Google map 信息窗口中使用 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8250314/