Fix loadTemplate to handle null return from widgetNode.
authorMike Taylor <mike@indexdata.com>
Wed, 16 Apr 2014 11:24:28 +0000 (12:24 +0100)
committerMike Taylor <mike@indexdata.com>
Wed, 16 Apr 2014 11:24:28 +0000 (12:24 +0100)
src/mkws-team.js

index f956e55..1983508 100644 (file)
@@ -641,12 +641,15 @@ function team($, teamName) {
 
        if (template === undefined) {
            // Fall back to generic template if there is no team-specific one
+           var source;
            var node = widgetNode("Template_" + name);
-           if (!node.length) {
+           if (!node) {
                node = widgetNode("Template_" + name, "ALL");
            }
+            if (node) {
+               source = node.html();
+            }
 
-           var source = node.html();
            if (!source) {
                source = defaultTemplate(name);
            }