]> git.openstreetmap.org Git - rails.git/commitdiff
Abort a running data browser load before starting a new one
authorTom Hughes <tom@compton.nu>
Tue, 30 Jul 2013 20:30:16 +0000 (21:30 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 30 Jul 2013 20:30:16 +0000 (21:30 +0100)
app/assets/javascripts/index/browse.js

index e04a864f468c74e1f5d7ce58e53022c4b91780e7..07cff50f0f7cb14814d16bee8d7bde5fcc8d534d 100644 (file)
@@ -136,6 +136,8 @@ function initializeBrowse(map) {
     $("#browse_content").append(div);
   }
 
+  var dataLoader;
+
   function getData() {
     var bounds = locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds();
     var size = bounds.getSize();
@@ -164,7 +166,9 @@ function initializeBrowse(map) {
       }
     @*/
 
-    $.ajax({
+    if (dataLoader) dataLoader.abort();
+
+    dataLoader = $.ajax({
       url: url,
       success: function (xml) {
         clearStatus();
@@ -203,6 +207,8 @@ function initializeBrowse(map) {
         } else {
           displayFeatureWarning(features.length, maxFeatures, addFeatures);
         }
+
+        dataLoader = null;
       }
     });
   }