From a0213fd5a3f01961934862b8bd547a3621443952 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 16 Jan 2014 12:52:25 +0000 Subject: [PATCH] now calling our session_destroy also for etemplate2.clear(), this way we get also unloads from frameset templates --- etemplate/js/etemplate2.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index 3cb25cf5f9..4c74097349 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -121,6 +121,12 @@ etemplate2.prototype.clear = function() $j(window).off("."+this.uniqueId); } + // call our destroy_session handler, if it is not already unbind, and unbind it after + if (this.destroy_session) + { + this.destroy_session(); + this.unbind_unload(); + } if (this.widgetContainer != null) { // Un-register handler @@ -195,14 +201,16 @@ etemplate2.prototype._createArrayManagers = function(_data) */ etemplate2.prototype.bind_unload = function() { + this.destroy_session = jQuery.proxy(function(ev) + { + var request = egw.json(this.app+".etemplate_new.ajax_destroy_session.etemplate", + [this.etemplate_exec_id], null, null, false); + request.sendRequest(); + }, this); + if (!window.onbeforeunload) { - window.onbeforeunload = this.destroy_session = jQuery.proxy(function(ev) - { - var request = egw.json(self.egw().getAppName()+".etemplate_new.ajax_destroy_session.etemplate", - [this.etemplate_exec_id], null, null, false); - request.sendRequest(); - }, this); + window.onbeforeunload = this.destroy_session; } }; @@ -214,8 +222,8 @@ etemplate2.prototype.unbind_unload = function() if (window.onbeforeunload === this.destroy_session) { window.onbeforeunload = null; - delete this.destroy_session; } + delete this.destroy_session; }; /** @@ -223,12 +231,8 @@ etemplate2.prototype.unbind_unload = function() */ etemplate2.prototype.load = function(_name, _url, _data, _callback) { - if (_data.etemplate_exec_id) - { - this.bind_unload(); - } egw().debug("info", "Loaded data", _data); - var currentapp = _data.currentapp || window.egw_appName; + var currentapp = this.app = _data.currentapp || window.egw_appName; // Register a handler for AJAX responses egw(currentapp, window).registerJSONPlugin(etemplate2_handle_assign, this, 'assign'); @@ -298,6 +302,8 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback) { window.egw_app_header(_data.app_header); } + // bind our unload handler + this.bind_unload(); } var _load = function() {