From f9914e069c193a36f59e5bcbf3c9fcffdba1225d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Mon, 15 Aug 2011 10:04:37 +0000 Subject: [PATCH] Fixed problem with getValues iterating over widgets which are in proxied templates --- etemplate/js/et2_template.js | 13 ++----------- etemplate/js/et2_widget.js | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/etemplate/js/et2_template.js b/etemplate/js/et2_template.js index 29d479fa60..9ade66ce3b 100644 --- a/etemplate/js/et2_template.js +++ b/etemplate/js/et2_template.js @@ -148,17 +148,8 @@ var et2_template = et2_DOMWidget.extend({ return this.div; }, - getValues: function(_target) { - if (this.proxiedTemplate) - { - return this.proxiedTemplate.getValues(_target); - } - else if (!this.isProxied) - { - return this._super(_target); - } - - return _target; + isInTree: function() { + return this._super(!this.isProxied); } }); diff --git a/etemplate/js/et2_widget.js b/etemplate/js/et2_widget.js index 4c96208145..33ff1dbbd7 100644 --- a/etemplate/js/et2_widget.js +++ b/etemplate/js/et2_widget.js @@ -315,7 +315,7 @@ var et2_widget = Class.extend({ _type = et2_widget; } - if (this.instanceOf(_type)) + if (this.isInTree() && this.instanceOf(_type)) { _callback.call(_context, this); } @@ -326,6 +326,30 @@ var et2_widget = Class.extend({ } }, + /** + * Returns true if the widget currently resides in the visible part of the + * widget tree. E.g. Templates which have been cloned are not in the visible + * part of the widget tree. + * + * @param _vis can be used by widgets overwriting this function - simply + * write + * return this._super(inTree); + * when calling this function the _vis parameter does not have to be supplied. + */ + isInTree: function(_vis) { + if (typeof _vis == "undefined") + { + _vis = true; + } + + if (this._parent) + { + return _vis && this._parent.isInTree(); + } + + return _vis; + }, + isOfSupportedWidgetClass: function(_obj) { for (var i = 0; i < this.supportedWidgetClasses.length; i++) @@ -529,7 +553,7 @@ var et2_widget = Class.extend({ // Check whether the entry is really undefined if (typeof _target[_widget.id] != "undefined") { - et2_debug("error", "Overwriting value of '" + this.id + + et2_debug("error", "Overwriting value of '" + _widget.id + "', id exists twice!"); }