Hello,
I would like just to know if i need to use:
Ti.UI.currentTabto 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.
Ti.UI.currentTab.open(back_window)
Your Answer
Think you can help? Login to answer this question!