Stash query for subsequent inspection
[mkws-moved-to-github.git] / src / mkws-widget.js
index 534e4b3..3def9e3 100644 (file)
@@ -132,10 +132,15 @@ widget.autosearch = function(widget) {
         alert("This page has a MasterKey widget that needs a query specified by the '" + name + "' variable");
       }
     }
-  }
 
-  widget.team.queue("ready").subscribe(function() {
-    if (query) {
+    // Stash this for subsequent inspection
+    widget.team.config().query = query;
+
+    widget.team.queue("ready").subscribe(function() {
+      // Postpone testing for the configuration items: these are not
+      // yet set for Record subclass widgets that fill them in in the
+      // subclass, as widget.autosearch is called in the superclass,
+      // before the subclass fiddles with the configuration.
       var sortOrder = widget.config.sort;
       var maxrecs = widget.config.maxrecs;
       var perpage = widget.config.perpage;
@@ -155,8 +160,8 @@ widget.autosearch = function(widget) {
       widget.log(s);
 
       widget.team.newSearch(query, sortOrder, maxrecs, perpage, limit, targets, targetfilter);
-    }
-  });
+    });
+  }
 };