While browsing through some questions, I stumbled upon this one: How to load another js file on a button click in titanium
I noticed that there are two different methods for opening windows in titanium. I'm curious if there are any significant performance discrepancies or advantages between the two approaches. For more information, I've been studying the documentation available here:
It's worth noting that I am not using Alloy.
Does anyone have insights into the advantages of each method? Below are snippets of the code for reference.
Method 1
var win = Ti.UI.createWindow({
backgroundColor : 'white',
url : 'home.js' //Path to your js file
});
win.open();
home.js
var myWin = Ti.UI.currentWindow;
//You can add your controls here and do your stuff.
// Note that never try to open myWin in this page since you've already opened this window
Method 2
//In your current page
loginbutton.addEventListener('click', function(e) {
var Home = require('/ui/common/Home');
var homePage = new Home();
homePage.open();
});
Home.js
function Home() {
var self = Ti.UI.createWindow({
layout : 'vertical',
backgroundColor:'white'
});
//Do your stuff here
//Add other controls here
return self;
}
module.exports = Home;