The Overview
I am fairly new to Titanium and I decided to finally start working with SQLite and some new UI features. I opted for the TabGroup as I felt that would be the best option. However I'm having a few issues. I am trying to simply get some quotes which have been inserted to a table (tested and working, I alerted them out and it worked) and I wish to display them out in the wiseWords tab, so the user can view them.
The Code
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 Error(s)
Runetime Error
Location: alloy/controllers/index.js
Uncaught TypeError: Cannot call method 'add' of undefined.
Source: $.wiseWordsWindow.add(addQuote);
To Clarify...
I understand what the error means, but don't understand why it is being thrown.
- Why can't I access the view for wiseWords.xml in index.js even though wiseWords is referenced in index.xml through the
<Require>
tag?
Aucun commentaire:
Enregistrer un commentaire