Problem
Closing a nav group causes the open window's JavaScript to be interpreted and run again, as if it were being opened for the first time.
Reproduction
Drop the following in an app.js win1.js and win2.js, respectively.
- When you run it, "win1" (a nav group) will be opened
- You'll see an alert ("Win 1 Opened!").
- After 1 second, win1 will be closed and win2 will be opened.
- You'll see an alert ("Win 2 Opened!") followed by another ("Win 1 Opened!").
var win1 = Ti.UI.createWindow();
win1.add(Titanium.UI.iPhone.createNavigationGroup({
window: Titanium.UI.createWindow({
navBarHidden: true,
backgroundColor: '#f00',
url: 'win1.js'
})
}));
var win2 = Titanium.UI.createWindow({
backgroundColor: '#0f0',
url: 'win2.js'
});
win1.open();
setTimeout(function() {
win2.open({transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT});
win1.close();
}, 1000);
alert('Win 1 Opened!');
alert('Win 2 Opened!');
Workaround
This isn't really a workaround, but if you do not close the nav group, this bug won't show up. Hide it instead (call win1.hide() instead of win1.close() and the bug will go away).
Associated Helpdesk Ticket
http://appc.me/c/APP-422396
Passed as expected on: iPad 3rd Gen 4.0.2 iPad 2 4.3.2 iPhone 4 4.2.10 SDK: version=1.8.0 timestamp=08/26/11 14:53 githash=8e978eb...