From 3b57659536381c3b93ceadbdc99e7bd792ccf6e2 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 10 Jan 2014 15:54:35 +0000 Subject: [PATCH] Defer binding to window resize until after loading is finished. --- etemplate/js/etemplate2.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index 73ff791bba..75cff996ed 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -93,9 +93,6 @@ function etemplate2(_container, _menuaction) // List of templates (XML) that are known, but not used. Indexed by id. this.templates = {}; - - // Connect to the window resize event - $j(window).resize(this, function(e) {e.data.resize();}); } /** @@ -118,6 +115,9 @@ etemplate2.prototype.resize = function() */ etemplate2.prototype.clear = function() { + // Remove any handlers on window (resize) + $j(window).off("."+this.uniqueId); + if (this.widgetContainer != null) { // Un-register handler @@ -289,6 +289,9 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback) // Inform the widget tree that it has been successfully loaded. this.widgetContainer.loadingFinished(deferred); + // Connect to the window resize event + $j(window).on("resize."+this.uniqueId, this, function(e) {e.data.resize();}); + // Insert the document fragment to the DOM Container this.DOMContainer.appendChild(frag);