Walk across all MKWS nodes twice: once to make teams, then to make widgets.
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 8c102b5..e1bcd06 100644 (file)
@@ -1473,6 +1473,14 @@ function team($, teamName) {
                    mkws.teams[tname] = team(j, tname);
                    debug("Made MKWS team '" + tname + "'");
                }
+           });
+       });
+       // Second pass: make the individual widget objects. This has
+       // to be done separately, and after the team-creation, since
+       // that sometimes makes new widget nodes (e.g. creating
+       // mkwsTermlists instead mkwsResults.
+       $('[class^="mkws"],[class*=" mkws"]').each(function () {
+           mkws.handleNodeWithTeam(this, function(tname, type) {
                var myTeam = mkws.teams[tname];
                var myWidget = widget(j, myTeam, type, this);
            });