From: John Firebaugh Date: Mon, 22 Apr 2013 23:23:29 +0000 (-0700) Subject: Fix search result link behavior (systemed/iD#1329) X-Git-Tag: live~5018^2~4 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/fd8a77552600ed2bff0bda0f0fd524a07998df4f Fix search result link behavior (systemed/iD#1329) --- diff --git a/app/views/site/id_iframe.html.erb b/app/views/site/id_iframe.html.erb index 515c0e807..b4cfaf461 100644 --- a/app/views/site/id_iframe.html.erb +++ b/app/views/site/id_iframe.html.erb @@ -47,9 +47,14 @@ parent.$("body").on("click", "a.set_position", function (e) { e.preventDefault(); var data = parent.$(this).data(); - id.map().centerZoom( - [data.lon, data.lat], - Math.max(data.zoom || 15, 13)); + + // 0ms timeout to avoid iframe JS context weirdness. + // http://bl.ocks.org/jfirebaugh/5439412 + setTimeout(function() { + id.map().centerZoom( + [data.lon, data.lat], + Math.max(data.zoom || 15, 13)); + }, 0); }); var maximized = false;