Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

code in window - '.js' files executed when ?

I observed a strange behavior.

The app has a tabGroub with 3 window (in extra '.js' files).
In the main app.js i listen to events fired by those windows.

Titanium.App.addEventListener('onWindowInitialized', function(e){...});

At the end of every window.js files i fire that event.
Titanium.App.fireEvent('onWindowInitialized');

Now the strange behavior:
When i start the simulator for the first time, only the first active window of the tabGroub fires.

But when i start the simulator again, all 3 windows fire the event.

Question:
Is the code in window.js files executed, when the tab is selected or when the tabGroup is created. Why is it inconsistent ?

— asked September 21st 2010 by David Waith
  • files
  • iphone
  • js
0 Comments

1 Answer

  • Hi!
    To my knowledge, the windows are only loaded on demand, so not until you focus them for the first time.
    Are you sure each of the other windows are firing the event, and that it's not just some kind of logging issue?
    If you add

    Titanium.App.fireEvent('onWindowInitialized', { name: "myWindow1" });
    

    you'll see where it came from.

    /Jacob

    — answered September 22nd 2010 by Jacob Waller
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.