From bdb148d1676c254deb78a1ef7b4e5b9d54b272db Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 1 Apr 2013 18:35:49 +0000 Subject: [PATCH] Make sure widgetContainer is initialized before loading, prevents timing problems --- etemplate/js/etemplate2.js | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index fcab554333..780cf00953 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -193,8 +193,29 @@ etemplate2.prototype.load = function(_name, _url, _data) // Create the document fragment into which the HTML will be injected var frag = document.createDocumentFragment(); - // Asynchronously load the XET file (code below is executed ahead of the - // code in the loadXMLFromURL function) + + // Clear any existing instance + this.clear(); + + // Create the basic widget container and attach it to the DOM + this.widgetContainer = new et2_container(null); + this.widgetContainer.setApiInstance(egw(appname, egw.elemWindow(this.DOMContainer))); + this.widgetContainer.setInstanceManager(this); + this.widgetContainer.setParentDOMNode(this.DOMContainer); + + // store the id to submit it back to server + if(_data) { + this.etemplate_exec_id = _data.etemplate_exec_id; + } + + // set app_header + if (window.opener) { // popup + document.title = _data.app_header; + } else { + // todo for idots or jdots framework + } + + // Asynchronously load the XET file et2_loadXMLFromURL(_url, function(_xmldoc) { // Scan for templates and store them @@ -224,27 +245,6 @@ etemplate2.prototype.load = function(_name, _url, _data) this.resize(); }, this); - // Clear any existing instance - this.clear(); - - // Create the basic widget container and attach it to the DOM - this.widgetContainer = new et2_container(null); - this.widgetContainer.setApiInstance(egw(appname, egw.elemWindow(this.DOMContainer))); - this.widgetContainer.setInstanceManager(this); - this.widgetContainer.setParentDOMNode(this.DOMContainer); - - // store the id to submit it back to server - if(_data) { - this.etemplate_exec_id = _data.etemplate_exec_id; - } - - // set app_header - if (window.opener) { // popup - document.title = _data.app_header; - } else { - // todo for idots or jdots framework - } - // Split the given data into array manager objects and pass those to the // widget container this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));