Skip to content

Instantly share code, notes, and snippets.

@kellymredd
Created July 15, 2011 13:42
Show Gist options
  • Save kellymredd/1084712 to your computer and use it in GitHub Desktop.
Save kellymredd/1084712 to your computer and use it in GitHub Desktop.
create multiple windows from reusable function
var ns = {};
(function(){
ns.ui = {};
ns.ui.createNewWindow = function(url){
return Ti.UI.createWindow({url:url});
}
ns.ui.createBaseWindow = function(_args) {
var win = Ti.UI.createWindow({title:_args.title});
win.add(Ti.UI.createLabel({
color: '#576996',
height: 20,
textAlign: 'center',
top: 15,
text: 'Window 1'
}));
var aButton = Titanium.UI.createButton({
title: 'Open new window!',
width: 100,
height: 35,
top: 100,
url: 'file/to/open.js'
});
aButton.addEventListener('click', function (e) {
var url = e.source.url;
var win = ns.ui.createNewWindow(url);
win.open();
});
win.add(aButton);
return win;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment