Created
January 24, 2012 20:21
-
-
Save benbahrenburg/1672333 to your computer and use it in GitHub Desktop.
CommonJS Tabgroup Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.AppTabGroup = function() { | |
//Thanks Kevin Whinnery for the sample | |
//https://github.com/appcelerator-developer-relations/Forging-Titanium/blob/master/ep-006 | |
var instance = Ti.UI.createTabGroup(); | |
//loop through tab objects and add them to the tab group | |
for (var i = 0, l = arguments.length; i < l; i++) { | |
var tab = Ti.UI.createTab(arguments[i]); | |
//on initialization, we track the current tab as the first one added | |
if (i === 0) { | |
instance.currentTab = tab; | |
} | |
instance.addTab(tab); | |
} | |
//track the current tab for the tab group | |
instance.addEventListener('focus', function(e) { | |
instance.currentTab = e.tab; | |
}); | |
return instance; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment