Skip to content

Instantly share code, notes, and snippets.

@tonylukasavage
Last active December 12, 2015 08:19
Show Gist options
  • Save tonylukasavage/4743544 to your computer and use it in GitHub Desktop.
Save tonylukasavage/4743544 to your computer and use it in GitHub Desktop.
// save a global reference to the tabgroup that can be
// accessed in any controller
Alloy.Globals.tabgroup = $.index;
$.index.setActiveTab(1));
$.index.open();
function doClick(e) {
console.log('Label Click From Tab 1');
}
function doClick(e) {
console.log('Label Click From Tab 2');
// This doesn't work because you are trying to access
// $.index, which doesn't exist in this controller.
// If you want to access the tabgroup, use the global
// reference we saved in the index.js controller
// $.index.setActiveTab(0); // THIS DOESN'T WORK!!!!
Alloy.Globals.tabgroup.setActiveTab(0);
}
<Alloy>
<TabGroup>
<Require src="tab1" />
<Require src="tab2" />
</TabGroup>
</Alloy>
<Alloy>
<Tab id="tab1" title="Tab 1">
<Window id="winTab1">
<Label id="t" onClick="doClick">My Label</Label>
</Window>
</Tab>
</Alloy>
<Alloy>
<Tab id="tab2" title="Tab 2">
<Window id="winTab2">
<Label id="t" onClick="doClick">My Label</Label>
</Window>
</Tab>
</Alloy>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment