window with button back

You must Login before you can answer or comment on any questions.

Hello,

I would like just to know if i need to use:

Ti.UI.currentTab
to open a new windows with the button "back" or i can use something else ?

Because i have some problem, ... no result for Ti.UI.currentTab

2 Answers

I have never had any luck with Ti.UI.currentTab. I don't think it works.

You have to get the current tab another way. Just keep track of the TabGroup itself, and then call getActiveTab() on the TabGroup. Once you have that tab reference, you can call open() on it.

Obviously, you can't use globals to track the TabGroup. You can use a CommonJS module, though. Example:

TabGroupTracker.js:

var _tabGroup = null;
 
function TabGroupTracker ()
{
}
 
TabGroupTracker.setTabGroup = function (tg)
{
    _tabGroup = tg;
}
 
TabGroupTracker.openWindow = function (win)
{
    _tabGroup.getActiveTab().open (win);
}
 
module.exports = TabGroupTracker;
When you create the TabGroup, do this:

app.js

var tg = Ti.UI.createTabGroup ({...});
var tgt = require ('TabGroupTracker');
tgt.setTabGroup (tg);
When you want to open a window on the current tab (from any module in your application), do this:
var win = Ti.UI.createWindow ({...});
var tgt = require ('TabGroupTracker');
tgt.openWindow (win);
This is rough code; I haven't tested it directly. But it should give you a good starting point.

I offer a more robust solution as part of the TitanUp library, but that might be more code than you want to add to your application.

— answered 10 months ago by Jason Priebe
answer permalink
2 Comments
  • Thx, i will try this =)

    — commented 10 months ago by Rebmann Guillaume

  • I need to use this if i want to make a menu like facebook because the tab is not working :(

    I found a source code to create this menu, but i don't really understand ... the source code use 3 window to creat the menu :(

    — commented 10 months ago by Rebmann Guillaume

Your Answer

Think you can help? Login to answer this question!