Move auto-searching code out of Records widget into
authorMike Taylor <mike@indexdata.com>
Wed, 2 Apr 2014 16:02:15 +0000 (17:02 +0100)
committerMike Taylor <mike@indexdata.com>
Wed, 2 Apr 2014 16:02:15 +0000 (17:02 +0100)
mkws.maybeAutosearch utility function.

src/mkws-widgets.js

index be802dd..4df81d7 100644 (file)
@@ -265,6 +265,11 @@ mkws.registerWidgetType('Records', function() {
        }
     });
 
+    mkws.maybeAutosearch(that);
+});
+
+
+mkws.maybeAutosearch = function(that) {
     var query = that.config.autosearch;
     if (query) {
        if (query.match(/^!param!/)) {
@@ -284,7 +289,7 @@ mkws.registerWidgetType('Records', function() {
            }
        }
 
-       this.team.queue("ready").subscribe(function() {
+       that.team.queue("ready").subscribe(function() {
            var sortOrder = that.config.sort;
            var perpage = that.config.perpage;
            var limit = that.config.limit;
@@ -301,7 +306,7 @@ mkws.registerWidgetType('Records', function() {
            that.team.newSearch(query, sortOrder, perpage, limit, targets, targetfilter);
        });
     }
-});
+};
 
 
 mkws.registerWidgetType('Navi', function() {