]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Merge remote-tracking branch 'upstream/pull/5686'
[rails.git] / app / assets / javascripts / index.js
index 9b825caad0aa77c76932cc3d0c163f6d4d66537c..810327e3fe15bd48a13dd4f5212bcb3bf932fbb7 100644 (file)
@@ -39,6 +39,14 @@ $(document).ready(function () {
 
     $("#sidebar_loader").show().addClass("delayed-fade-in");
 
+    // Prevent caching the XHR response as a full-page URL
+    // https://github.com/openstreetmap/openstreetmap-website/issues/5663
+    if (content_path.indexOf("?") >= 0) {
+      content_path += "&xhr=1";
+    } else {
+      content_path += "?xhr=1";
+    }
+
     $("#sidebar_content")
       .empty();
 
@@ -300,8 +308,9 @@ $(document).ready(function () {
     };
 
     function addObject(type, id, center) {
+      var hashParams = OSM.parseHash(window.location.hash);
       map.addObject({ type: type, id: parseInt(id, 10) }, function (bounds) {
-        if (!window.location.hash && bounds.isValid() &&
+        if (!hashParams.center && bounds.isValid() &&
             (center || !map.getBounds().contains(bounds))) {
           OSM.router.withoutMoveListener(function () {
             map.fitBounds(bounds);