Make sure there's a template name before requesting it from server

This commit is contained in:
Nathan Gray 2012-07-23 23:51:47 +00:00
parent 9abe56ff94
commit 0fa5e2ee49

View File

@ -102,21 +102,24 @@ var et2_template = et2_DOMWidget.extend({
splitted = this.id.split('.'); splitted = this.id.split('.');
var path = this.egw().webserverUrl + "/" + splitted.shift() + "/templates/default/" + splitted.join('.') + ".xet"; var path = this.egw().webserverUrl + "/" + splitted.shift() + "/templates/default/" + splitted.join('.') + ".xet";
et2_loadXMLFromURL(path, function(_xmldoc) { if(splitted.length)
var templates = {}; {
// Scan for templates and store them et2_loadXMLFromURL(path, function(_xmldoc) {
for(var i = 0; i < _xmldoc.childNodes.length; i++) { var templates = {};
var template = _xmldoc.childNodes[i]; // Scan for templates and store them
if(template.nodeName.toLowerCase() != "template") continue; for(var i = 0; i < _xmldoc.childNodes.length; i++) {
templates[template.getAttribute("id")] = template; var template = _xmldoc.childNodes[i];
} if(template.nodeName.toLowerCase() != "template") continue;
templates[template.getAttribute("id")] = template;
}
// Read the XML structure of the requested template // Read the XML structure of the requested template
this.loadFromXML(templates[this.id]); this.loadFromXML(templates[this.id]);
// Inform the widget tree that it has been successfully loaded. // Inform the widget tree that it has been successfully loaded.
this.loadingFinished(); this.loadingFinished();
}, this); }, this);
}
return; return;
} }
} }