You really should not use the url
property for this very reason, as it makes a completely different JS context, instead you should wrap your tab window (restaurants.js) in a CommonJS style module.
But, if you dont want to make this modular, you should just be able to append the tabGroup as a property of the window like this:
var restaurant = Titanium.UI.createWindow({
tabBarHidden:true,
color: '#FFF',
url: 'restaurants.js',
navBarHidden:false,
statusBarStyle: Titanium.UI.iPhone.StatusBar.TRANSLUCENT_BLACK
});
restaurant.myTabGroup = tabGroup;
Then you can navigate to a different tab like this, inside of your restaurants.js file:
// Set active tab to the third tab
Titanium.UI.currentWindow.myTabGroup.setActiveTab(3).open();
I would highly recommend going the module rout though.
Modules
EDIT: Here is an attempt at modularizing your window using parasitic inheritance. Take a look at this guide for more detail.
function MyWindow(parentTabGroup) {
var restaurant = Titanium.UI.createWindow({
tabBarHidden:true,
color: '#FFF',
navBarHidden:false,
statusBarStyle: Titanium.UI.iPhone.StatusBar.TRANSLUCENT_BLACK
});
// Here is where you add all the controls and views you had put inside
// 'restaurant.js'.....
// Also, if you have an event listener you can call the tab group
button.addEventListener('click', function(e) {
parentTabGroup.setActiveTab(3);
});
return restaurant;
}
module.exports = MyWindow;
So now you can create your window and add it to the tab group like this:
var MyWindow = require('MyWindow');
var mywin = new MyWindow(tabGroup);
var tab2 = Ti.UI.createTab({
title:"x",
color: '#FFF',
backgroundColor:'#00c0f3',
window: mywin
});