Hello
i'm trying to open a window when the button 'Registerguide' is clicked. But the window must contain a button in the upper left corner so the user can go back to the homepage. So the registerwindow must be a child of the main app.js window.
I managed to do this on other windows, but not in the app.js file I used this code:
function DateFeedWindow(title) { var self = Ti.UI.createWindow({ title:title, backgroundColor:'red' }); var button = Ti.UI.createButton({ height:44, width:200, title:L('openWindow'), top:20 }); self.add(button); button.addEventListener('click', function() { //containingTab attribute must be set by parent tab group on //the window for this work self.containingTab.open(Ti.UI.createWindow({ url: 'ui/ResultWindow.js' })); }); return self; }; module.exports = DateFeedWindow;The app.js file where the button Registerguide has to guide the users to the RegisterWindow.js file, leaving a 'automatic button' that goes right back to the home login screen.
// this sets the background color of the master // UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#fff'); // create tab group var tabGroup; var win = Titanium.UI.createWindow({ title:'TabViewLogin', tabBarHidden:false, }); // //LOGIN USER INTERFACE // //LABEL Welkom! var label1 = Ti.UI.createLabel({ text:'Welcome!', top:10, left:15, height:'auto', color:'#989898', font:{fontSize:16,fontWeight:'bold'} }); win.add(label1); //BUTTON naar Registermenu var Registerguide = Titanium.UI.createButton({ backgroundImage:'/images/pill5.png', title:L('Join us!'), textAlign : 'left', color: '#FFFFFF', top:40, width:300, height:40, borderRadius:1, font:{fontFamily:'Arial',fontWeight:'bold',fontSize:16} }); win.add(Registerguide); //LABEL We only need a few things... var label2 = Ti.UI.createLabel({ text:'We only need a few things to get you strarted.', top:90, left:15, height:'auto', color:'#989898', font:{fontSize:9,fontWeight:'bold'} }); win.add(label2); //LABEL Already have an acount? var label3 = Ti.UI.createLabel({ text:'Already have an account?', top:140, left:15, height:'auto', color:'#989898', font:{fontSize:16,fontWeight:'bold'} }); win.add(label3); //USERNAME FIELD var username = Titanium.UI.createTextField({ color:'#336699', top:170, left:10, width:300, height:40, hintText:'Username', keyboardType:Titanium.UI.KEYBOARD_DEFAULT, returnKeyType:Titanium.UI.RETURNKEY_DEFAULT, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); win.add(username); //PASSWORD FIELD var password = Titanium.UI.createTextField({ color:'#336699', top:220, left:10, width:300, height:40, hintText:'Password', passwordMask:true, keyboardType:Titanium.UI.KEYBOARD_DEFAULT, returnKeyType:Titanium.UI.RETURNKEY_DEFAULT, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); win.add(password); //LABEL Forgot your password? var label4 = Ti.UI.createLabel({ text:'Forgot your password?', top:270, left:15, height:'auto', color:'#989898', font:{fontSize:9,fontWeight:'bold'} }); win.add(label4); //BUTTON LOGIN var loginBtn = Titanium.UI.createButton({ backgroundImage:'/images/pill4.png', title:'Login and Mingle.', top:300, width:300, height:40, color: '#FFFFFF', font:{fontFamily:'Arial',fontWeight:'bold',fontSize:16} }); win.add(loginBtn); win.open(); //Action voor de login button + fieldcheck var loginReq = Titanium.Network.createHTTPClient(); loginBtn.addEventListener('click',function(e) { if (username.value != '' && password.value != '') { loginReq.open("POST","http://localhost:8888/php/post_auth.php"); var params = { username: username.value, password: Ti.Utils.md5HexDigest(password.value) }; loginReq.send(params); } else { alert("Username/Password are required"); } }); //Datahandler Login loginReq.onload = function() { var json = this.responseText; var response = JSON.parse(json); if (response.logged == true) { username.blur(); password.blur(); Ti.App.fireEvent('grantEntrance', { name:response.name, email:response.email }); win.close(); } else { alert(response.message); } }; Titanium.App.addEventListener('logout', function(e) { win.open(); tabGroup.close(); }); Ti.App.addEventListener('grantEntrance', function(event) { if ( tabGroup == undefined ) { tabGroup = Titanium.UI.createTabGroup(); //MAIN NAVIGATIE WINDOWS var DateFeedWindow = require('ui/DateFeedWindow'); var BroadcastWindow = require('ui/BroadcastWindow'); var MessagesWindow = require('ui/MessagesWindow'); var MyprofileWindow = require('ui/MyprofileWindow'); var win1 = new DateFeedWindow(L('Datefeed')); var win2 = new BroadcastWindow(L('Your Broadcast')); var win3 = new MessagesWindow(L('Messages')); var win4 = new MyprofileWindow(L('Settings')); var tab1 = Ti.UI.createTab({ title: L('Datefeed'), icon: '/images/KS_nav_ui.png', window: win1 }); win1.containingTab = tab1; var tab2 = Ti.UI.createTab({ title: L('Broadcast'), icon: '/images/KS_nav_views.png', window: win2 }); win2.containingTab = tab2; var tab3 = Ti.UI.createTab({ title: L('Messages'), icon: '/images/KS_nav_views.png', window: win3 }); win3.containingTab = tab3; var tab4 = Ti.UI.createTab({ title: L('My Profile'), icon: '/images/KS_nav_views.png', window: win4 }); win3.containingTab = tab4; // add tabs tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.addTab(tab3); tabGroup.addTab(tab4); // open tab group win.close(); tabGroup.open(); } });Thanks in advance guys
1 Answer
the other windows work fine because the tabGroup gives you that functionality by default. Can you provide a smaller example with just the window that is not working properly?
Your Answer
Think you can help? Login to answer this question!