Towards multiple search forms.
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index ecba8da..b5dc51d 100644 (file)
@@ -404,7 +404,14 @@ function _make_mkws_team($, teamName) {
     // wait until the DOM is ready
     function domReady ()
     {
-       document.mkwsSearchForm.onsubmit = onFormSubmitEventHandler;
+       $('.mkwsSearchForm').each(function (i, obj) {
+           var node = this;
+           debug("adding class 'foo' to node " + node);
+           mkws.handle_node_with_team(node, function(tname) {
+               $(node).submit(onFormSubmitEventHandler);
+           });
+       });
+
        document.mkwsSearchForm.mkwsQuery.value = '';
        if (document.mkwsSelect) {
            if (document.mkwsSelect.mkwsSort)
@@ -863,11 +870,16 @@ function _make_mkws_team($, teamName) {
        // For some reason, doing this programmatically results in
        // document.mkwsSearchForm.mkwsQuery being undefined, hence the raw HTML.
        debug("HTML search form");
-       $("#mkwsSearch").html('\
-<form name="mkwsSearchForm" action="" >\
-  <input id="mkwsQuery" class="mkwsQuery mkwsTeam_AUTO" type="text" size="' + mkws_config.query_width + '" />\
-  <input id="mkwsButton" class="mkwsButton mkwsTeam_AUTO" type="submit" value="' + M('Search') + '" />\
+       $('.mkwsSearch').each(function (i, obj) {
+           var node = this;
+           mkws.handle_node_with_team(node, function(tname) {
+               $(node).html('\
+<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
+  <input id="mkwsQuery" class="mkwsQuery mkwsTeam_' + tname + '" type="text" size="' + mkws_config.query_width + '" />\
+  <input id="mkwsButton" class="mkwsButton mkwsTeam_' + tname + '" type="submit" value="' + M('Search') + '" />\
 </form>');
+           });
+       });
 
        debug("HTML records");
        // If the application has an #mkwsResults, populate it in the
@@ -1297,7 +1309,7 @@ function _mkws_jquery_plugin ($) {
        // Find all nodes with class (NOT id) mkwsRecords, and
        // determine their team from the mkwsTeam_* class. So:
        //      <div class="mkwsRecords mkwsTeam_foo"/>
-       $('.mkwsResults, .mkwsRecords, .mkwsTermlists').each(function () {
+       $('.mkwsSearch, .mkwsResults, .mkwsRecords, .mkwsTermlists').each(function () {
            var node = this;
            mkws.handle_node_with_team(node, function(tname) {
                if (mkws.teams[tname]) {