Created
June 21, 2010 14:06
-
-
Save jmwhittaker/446887 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Trying to get a tabGroup working inside a Modal window. My Main app already has a tabGroup, the modal appear over the top. | |
I get the tabGroup to appear, but trying to open new windows just silently fails. | |
*/ | |
var tabGroup = Ti.UI.createTabGroup(); | |
var win1 = Ti.UI.createWindow({ | |
title:"Test" | |
}); | |
var win2 = Ti.UI.createWindow({ | |
title:"Blank" | |
}); | |
var tab1 = Ti.UI.createTab({ | |
window:win1, | |
title:"Test" | |
}); | |
var tab2 = Ti.UI.createTab({ | |
window:win2, | |
title:"Blank" | |
}); | |
tabGroup.addTab(tab1); | |
tabGroup.addTab(tab2); | |
var button = Ti.UI.createButton({ | |
title:"Open", | |
width:80, | |
height:40 | |
}); | |
win1.add(button); | |
button.addEventListener('click',function() | |
{ | |
try | |
{ | |
// by default the modal window has a nav bar | |
// since we're embedding a navgroup inside the modal | |
// window which also has a nav bar, we ask him to hide it | |
var modal = Ti.UI.createWindow({ | |
navBarHidden:true, | |
backgroundColor:"red" | |
}); | |
var modalWin = Ti.UI.createWindow({ | |
backgroundColor:"red", | |
tabBarHidden:true | |
}); | |
var table = Ti.UI.createTableView({ | |
style:Ti.UI.iPhone.TableViewStyle.GROUPED, | |
data:[{title:"Hello World 1"},{title:"Hello World"}] | |
}); | |
modalWin.add(table); | |
var done = Titanium.UI.createButton({ | |
systemButton:Titanium.UI.iPhone.SystemButton.DONE | |
}); | |
modalWin.setRightNavButton(done); | |
done.addEventListener('click',function() | |
{ | |
modal.close(); | |
}); | |
//tabs | |
var tabG = Ti.UI.createTabGroup({}); | |
var tab1 = Ti.UI.createTab({ | |
window:modalWin, | |
title:"Test Tab 1" | |
}); | |
tabG.addTab(tab1); | |
modal.add(tabG); | |
tabG.open(); | |
table.addEventListener('click',function(e) | |
{ | |
alert('Clicked !'); | |
var w = Ti.UI.createWindow({ | |
title:e.rowData.title | |
}); | |
/* | |
Try to open this new window in current tab | |
How do I reference this second tabGroup? Ti.UI.currentTab fails too. | |
*/ | |
tabG.currentTab.open(win,{animated:true}); | |
}); | |
//modal.add(nav); | |
modal.open({modal:true}); | |
} | |
catch (E) | |
{ | |
Ti.API.error("ERROR " +E); | |
} | |
}); | |
tabGroup.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment