so i get this error saying Script Error = 'undefined' is not an object (evaluating 'currentWindowMore.add') but when i dismiss the error and run the app it does exactly what i want. so my question is how do i get rid of this error
so the situation is like this:
Ti.UI.setBackgroundColor('#fff');
var tabGroup = Titanium.UI.createTabGroup();
var winLeaderboard = Ti.UI.createWindow({
backgroundColor:'#fff',
title:'Leaderboard',
barColor:'#449ab0',
exitOnClose: true,
});
var winMore = Ti.UI.createWindow({
backgroundColor:'#fff',
title:'More',
barColor:'#449ab0',
exitOnClose: true,
url:'js/windowMore.js'
});
var tab1 = Titanium.UI.createTab({
icon:'images/nav_Leaderboard.png',
title:'Leaderboard',
window:winLeaderboard
});
var tab2 = Titanium.UI.createTab({
icon:'images/nav_More.png',
title:'More',
window:winMore
});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.open();
winLeaderboard.open();
upon clicking the tab "More" i go to a new window, here is the code for that
var currentWindowMore = Ti.UI.currentWindow;
var label = Ti.UI.createLabel({ text:'Testing window MORE', textAlign: 'center', });
currentWindowMore.add(label);
1 Answer
The problem is that you are trying to grab Ti.UI.currentWindow. At the time you fire that, you appear to be in file that declares your tabgroup.
You need to understand the contexts within which your code is running.
If your intent is to add the label to the window declared in windowMore.js, then you should use the Ti.UI.currentWindow call there, not in the context of the tabgroup creation.
If I'v read this all wrong, its because your question does lack a bit of the required information and lacks proper code formatting.
Missing from your question are a number of important pieces of information. I suggest you take a look at the Using Questions and Answers article, specifically the Q&A Question Checklist. The missing information is critical to reproducing problems in a test environment and often indicates other factors that cause the undesirable outcome you are experiencing.
Your Answer
Think you can help? Login to answer this question!