Time for action – sharing information between windows
To share information between windows perform the following steps:
Create a new blank mobile app by clicking on File | New | Titanium Project. Don't use a template as it will just generate code that gets in the way.
This application will be a single window app, so remove all of the code from
app.js
, replacing it with a single, self-executing function. This is a chapter about good code design so we are including it in this example. With the self-executing function inapp.js
, we can be sure that all variables within the app are enclosed within a function.Note
What is a self-generating function?
It's a function that executes as soon as it is defined. Notice in the following example that the function is enclosed in brackets and then has
()
to execute the function after the function definition. It is not necessary to enclose the function in brackets; it's just a good convention. These brackets at the end of the function definition cause the...