From 0fa5e2ee49ad4e2d79d142fdbac7b2616a971e55 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 23 Jul 2012 23:51:47 +0000 Subject: [PATCH] Make sure there's a template name before requesting it from server --- etemplate/js/et2_widget_template.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/etemplate/js/et2_widget_template.js b/etemplate/js/et2_widget_template.js index 6d7568b0ab..0cf0fba69e 100644 --- a/etemplate/js/et2_widget_template.js +++ b/etemplate/js/et2_widget_template.js @@ -102,21 +102,24 @@ var et2_template = et2_DOMWidget.extend({ splitted = this.id.split('.'); var path = this.egw().webserverUrl + "/" + splitted.shift() + "/templates/default/" + splitted.join('.') + ".xet"; - et2_loadXMLFromURL(path, function(_xmldoc) { - var templates = {}; - // Scan for templates and store them - for(var i = 0; i < _xmldoc.childNodes.length; i++) { - var template = _xmldoc.childNodes[i]; - if(template.nodeName.toLowerCase() != "template") continue; - templates[template.getAttribute("id")] = template; - } + if(splitted.length) + { + et2_loadXMLFromURL(path, function(_xmldoc) { + var templates = {}; + // Scan for templates and store them + for(var i = 0; i < _xmldoc.childNodes.length; i++) { + var template = _xmldoc.childNodes[i]; + if(template.nodeName.toLowerCase() != "template") continue; + templates[template.getAttribute("id")] = template; + } - // Read the XML structure of the requested template - this.loadFromXML(templates[this.id]); + // Read the XML structure of the requested template + this.loadFromXML(templates[this.id]); - // Inform the widget tree that it has been successfully loaded. - this.loadingFinished(); - }, this); + // Inform the widget tree that it has been successfully loaded. + this.loadingFinished(); + }, this); + } return; } }