The Situation
As a Titanium beginner, I recently decided to explore SQLite functionality and incorporate new UI features into my app. I chose the TabGroup for ease of use, but I've encountered some issues along the way. My goal is straightforward - retrieve quotes from a table (which I verified is working) and display them in the wiseWords tab for user viewing.
The Implementation
index.xml
<Alloy id="index">
<TabGroup>
<Require src="home"></Require>
<Require src="wiseWords"></Require>
<Require src="settings"></Require>
</TabGroup>
</Alloy>
index.js
$.index.open();
/** Create and populate the wise words table. **/
Alloy.Globals.createRequiredTables();
var selectWiseWordsSQL = "SELECT * FROM wise_words";
var selectWiseWords = Titanium.App.db.execute(selectWiseWordsSQL);
while (selectWiseWords.isValidRow()) {
/** Create labels for each quote. **/
var addQuote = Titanium.UI.createLabel({
text : selectWiseWords.fieldByName("saying") + " - " + selectWiseWords.fieldByName("quoted_by"),
});
/** Add quote to window (available in wiseWords.xml). **/
$.wiseWordsWindow.add(addQuote);
selectWiseWords.next();
}
selectWiseWords.close();
wiseWords.xml
<Alloy>
<Tab id="wiseWordsTab" title="Wise Words">
<Window id="wiseWordsWindow" class="container" title="Wise Words">
</Window>
</Tab>
</Alloy>
The Issue(s)
Runetime Error
Location: alloy/controllers/index.js
Uncaught TypeError: Cannot call method 'add' of undefined.
Source: $.wiseWordsWindow.add(addQuote);
To Clarify...
I comprehend the error message, but am puzzled as to why it's appearing.
- Why am I unable to access the view for wiseWords.xml in index.js despite wiseWords being referenced in index.xml using the
<Require>
tag?