Reputation: 12457
e.tabIndex contains nothing..?
I have application which has four tabs and
I would like to get the 'swipe' gesture and change the current active tab.
However I cant get the current activeTab.
Some sample code says you can get active tab number 'e.tabIndex' though...
my index.js
$.mainTabGroup.addEventListener('swipe',function(e){
var tabIndex = e.tabIndex;
var lastIndex = $.mainTabGroup.getTabs().length - 1;
Ti.API.info(tabIndex);// somehow null????
Ti.API.info(lastIndex);
//switch the tab here.
});
my index.xml
<Alloy>
<TabGroup backgroundColor="white" id="mainTabGroup">
<Tab id="byFav" title="fav" icon="KS_nav_views.png">
<Window title='fav'>
</Window>
</Tab>
<Tab id="byLatest" title="latest" icon="KS_nav_views.png">
<Window title='latest'>
</Window>
</Tab>
<Tab id="byCat" title="category" icon="KS_nav_views.png">
<Window>
</Window>
</Tab>
<Tab id="byDate" title=" icon="KS_nav_views.png">
<Window>
</Window>
</Tab>
</TabGroup>
</Alloy>
Upvotes: 0
Views: 185
Reputation: 2668
swipe event callback does not have any tabindex. You may get active tab using activeTab Property or getActiveTab method
$.mainTabGroup.addEventListener('swipe',function(e){
var tabIndex = $.mainTabGroup.activeTab; //using property
var tabIndex = $.mainTabGroup.getActiveTab(); // using method
});
Upvotes: 1