]> git.openstreetmap.org Git - rails.git/commitdiff
Fix P2 interaction with search links
authorJohn Firebaugh <john.firebaugh@gmail.com>
Thu, 18 Apr 2013 22:59:25 +0000 (15:59 -0700)
committerTom Hughes <tom@compton.nu>
Thu, 25 Apr 2013 16:37:57 +0000 (17:37 +0100)
Need to prevent the default action so that the page isn't
reloaded.

Also, since the click event binding uses delegation, it isn't
necessary to wrap it in $(document).ready().

app/views/site/_potlatch2.html.erb

index 535992f2fffcf9af960c7b94481dcb98f301c3f2..65ca9210e11734d4209c9d4fe9b12158102bf366 100644 (file)
   doSWF(params.lat, params.lon, params.zoom || 17);
   <% end -%>
 
-  $(document).ready(function () {
-    $("body").on("click", "a.set_position", function () {
-      var data = $(this).data();
+  $("body").on("click", "a.set_position", function (e) {
+    e.preventDefault();
 
-      $("#potlatch").each(function () {
-        this.setPosition(data.lat, data.lon, Math.max(data.zoom || 15, 13));
-      });
+    var data = $(this).data();
+
+    $("#potlatch").each(function () {
+      this.setPosition(data.lat, data.lon, Math.max(data.zoom || 15, 13));
     });
   });