From 11fe571e659f51cbe76671c9d5e03f7602dd5b74 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 20 Mar 2012 21:42:25 +0000 Subject: [PATCH] Instanciate the instance for the app based on template name when loading --- etemplate/js/et2_widget_template.js | 7 +++++-- etemplate/js/etemplate2.js | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_widget_template.js b/etemplate/js/et2_widget_template.js index 30e518b52a..74f2d952b6 100644 --- a/etemplate/js/et2_widget_template.js +++ b/etemplate/js/et2_widget_template.js @@ -64,9 +64,12 @@ var et2_template = et2_DOMWidget.extend({ if (this.id != "") { // Set the api instance to the first part of the name of the - // template + // template, if it's in app.function.template format var splitted = this.id.split('.'); - this.setApiInstance(egw(splitted[0], this._parent.egw().window)); + if(splitted.length == 3) + { + this.setApiInstance(egw(splitted[0], this._parent.egw().window)); + } // Check to see if XML is known var xml = null; diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index 5f6906e520..f18db062f3 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -159,6 +159,10 @@ etemplate2.prototype._createArrayManagers = function(_data) */ etemplate2.prototype.load = function(_name, _url, _data) { + // Appname should be first part of the template name + var split = _name.split('.'); + var appname = split[0]; + // Create the document fragment into which the HTML will be injected var frag = document.createDocumentFragment(); @@ -191,7 +195,7 @@ etemplate2.prototype.load = function(_name, _url, _data) // Create the basic widget container and attach it to the DOM this.widgetContainer = new et2_container(null); - this.widgetContainer.setApiInstance(egw(egw.elemWindow(this.DOMContainer))); + this.widgetContainer.setApiInstance(egw(appname, egw.elemWindow(this.DOMContainer))); this.widgetContainer.setInstanceManager(this); this.widgetContainer.setParentDOMNode(this.DOMContainer);