From 1a23b093d4a01edeb5853c223cc844e06b8d1390 Mon Sep 17 00:00:00 2001 From: Radu Cugut Date: Fri, 14 Oct 2011 20:22:41 +0300 Subject: [PATCH] remove the event handler of the windowToAdd 'close' event after its execution https://github.com/appcelerator-developer-relations/Forging-Titanium/issues/3 --- ep-002/Resources/NavigationController.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ep-002/Resources/NavigationController.js b/ep-002/Resources/NavigationController.js index 5bd58fd..8adbc2b 100644 --- a/ep-002/Resources/NavigationController.js +++ b/ep-002/Resources/NavigationController.js @@ -8,9 +8,16 @@ exports.NavigationController.prototype.open = function(/*Ti.UI.Window*/windowToO //grab a copy of the current nav controller for use in the callback var that = this; - windowToOpen.addEventListener('close', function() { + + // save the 'close' event handler into a variable (will be used to remove the event listener below) + var windowToOpen_closeEventHandler = function() { that.windowStack.pop(); - }); + // remove this function from the 'close' event lisetner => prevents to be triggered more than once + windowToOpen.removeEventListener('close', windowToOpen_closeEventHandler); + }; + + windowToOpen.addEventListener('close', windowToOpen_closeEventHandler); + //hack - setting this property ensures the window is "heavyweight" (associated with an Android activity) windowToOpen.navBarHidden = windowToOpen.navBarHidden || false;