Hi there,
I've built a prototype application which is just a 3-tab tab-group with 1 window each. So in essence
page1.xml, page1.tss, page.js
page2.xml, page2.tss, page2.js
page3.xml, page3.tss, page3.js
I want to use setActiveTab - To programatically control which tab to trigger from a custom button (i.e. not the tab group itself)
So inside say page2.js I try do this:
$.btnSettings.addEventListener("click", function() { $.tabGroup.setActiveTab(2); });I get an undefined error, and I just basically can't access the tab group nor the current Tab using the stadard Titanium 2 docs
Where $.tabGroup is also the ID in the index.xml file like so:
<TabGroup id='tabGroup'> <Require src="page1"/> <Require src="page2"/> <Require src="page3"/> </TabGroup>Any help would be amazing!
2 Answers
Accepted Answer
$.tabGroup will only reference the tabgroup you created in the view/controller that contains the tabgroup, in this case, it would only work in index.js, but not in page1.js, page2.js, or page3.js. If you want to be able to access the tabgroup globally, you'll need to create a global reference to it. You can do so by:
- Attaching a property to
Alloy.CFG, which is available in all controllers, that holds the reference to the tabgroup. - Create a standard commonjs module in "lib" that basically does the same thing as Alloy.CFG, a module for passing around global values.
Thanks for the reply.
So based on this structure, how would I use a file in /lib/ within a widget? as in with the require method?
Your Answer
Think you can help? Login to answer this question!