Skip to content

Instantly share code, notes, and snippets.

@benbahrenburg
Created January 24, 2012 20:21
Show Gist options
  • Save benbahrenburg/1672333 to your computer and use it in GitHub Desktop.
Save benbahrenburg/1672333 to your computer and use it in GitHub Desktop.
CommonJS Tabgroup Sample
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