Quellcode durchsuchen

Fixed timing issue with preview tables

Andrew Kane vor 8 Jahren
Ursprung
Commit
f7d5280d4f
1 geänderte Dateien mit 7 neuen und 3 gelöschten Zeilen
  1. 7 3
      app/views/blazer/queries/_form.html.erb

+ 7 - 3
app/views/blazer/queries/_form.html.erb

@@ -114,14 +114,18 @@
       },
       updateDataSource: function(dataSource) {
         this.dataSource = dataSource
-        var _this = this
+        var selectize = this.selectize
+        selectize.clearOptions()
+
+        if (this.tablesXhr) {
+          this.tablesXhr.abort()
+        }
 
-        $.getJSON(Routes.tables_queries_path({data_source: this.dataSource}), function(data) {
+        this.tablesXhr = $.getJSON(Routes.tables_queries_path({data_source: this.dataSource}), function(data) {
           var newOptions = []
           for (var i = 0; i < data.length; i++) {
             newOptions.push({text: data[i], value: data[i]})
           }
-          var selectize = _this.selectize
           selectize.clearOptions()
           selectize.addOption(newOptions)
           selectize.refreshOptions(false)