【发布时间】:2012-09-30 18:03:11
【问题描述】:
点击似乎触发了事件并设置了 cookie,但按 Enter 提交并没有设置 cookie,而是页面在没有 cookie 的情况下重定向。
function locationAuto() {
$('.search-location').focus(function () {
autocomplete = new google.maps.places.Autocomplete(this);
searchbox = this;
google.maps.event.addListener(autocomplete, 'place_changed', function () {
var thisplace = autocomplete.getPlace();
if (thisplace.geometry.location != null) {
$.cookie.raw = true;
$.cookie('location', searchbox.value, { expires: 1 });
$.cookie('geo', thisplace.geometry.location, { expires: 1 });
}
});
});
.search-location 是多个文本框上的一个类。 有一个提交按钮,可以从 cookie 中获取值并重定向(服务器端)
【问题讨论】:
-
这不是 Google Mapa API 问题。
-
它在 Google Maps API v3 Places Library 中
-
问题是关于在 DOM 元素上触发事件,而不是关于 Google Maps API。
标签: autocomplete google-places