I have created a real basic nav bar at the top so i wouldn't have to mess with the tab functions at the bottom.
I have 2 questions. I am first of all having problems trying to reference the extensions of .js files via url. See code. It says that it does not pull up properly.
So I went ahead and added functions and added the module.exprts to (tibook). So when i try and pull up tibook. I then get a scripting error saying that it can't find the variable.
So to recap it's not pulling up my ***.js files once i click on the nav bar at the top. And if it does pull it up i get a scripting error.
In this forum you see the app.js file along with the book.js file.
This is the main area here (app.js)
var win = Titanium.UI.createWindow({
// backgroundColor : 'white'
});
var tb1 = Titanium.UI.createTabbedBar({
labels : ['Sports', 'Map', 'Books', 'Contact'],
backgroundColor : '#336699',
top : 0,
style : Titanium.UI.iPhone.SystemButtonStyle.BAR,
height : 40,
width : '100%',
index : 1,
});
win.add(tb1);
var newWin = Ti.UI.createWindow({
url : 'book.js'
});
tb1.addEventListener('click', function(e) {
if(e.index == 0) {
var newWin = Ti.UI.createWindow({
url : 'book.js',
top : 41
});
newWin.open();
}
if(e.index == 1) {
var newWin = Ti.UI.createWindow({
url : 'info.js',
top : 41
});
newWin.open();
}
if(e.index == 2) {
var newWin = Ti.UI.createWindow({
url : 'map.js',
top : 41
});
newWin.open();
}
if(e.index == 3) {
var newWin = Ti.UI.createWindow({
url : 'galary.js',
top : 41
});
newWin.open();
}
})
win.open();
//var win = Titanium.UI.createWindow({
// title:"tittle",
// backgroundColor:"#FFFFFF",
//})
var label = Titanium.UI.createLabel({
backgroundImage: "images/what.png",
top: "10%",
width: "100%",
height: "12%",
textalign: "center",
})
// new button
var openWebpagenotification = Titanium.UI.createButton({
title:"Notifications",
backgroundImage: "images/notificationbutton.png",
width:"100%",
height:"12%",
top:"20%",
id: "Notifications",
url:"http://www.google.com/", color: '#000000'
});
openWebpagenotification.addEventListener("click", function(e){
// Create a window and add a webview to it that opens your url:
var webviewWindow = Titanium.UI.createWindow({title: 'Notifications', fullscreen: false});
var myWebView = Ti.UI.createWebView({url:e.source.url});
webviewWindow.add(myWebView);
// Will need a button to close the new window:
var closeButton = Titanium.UI.createButton({title:'Close', style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN});
webviewWindow.setLeftNavButton(closeButton);
closeButton.addEventListener('click',function(evt){
webviewWindow.close();
///////////////////////////////////////////////////////////////////////////////////// This is the book.js file.*************
function tibook() { var win = Titanium.UI.createWindow(); var win = Titanium.UI.createWindow({ // backgroundColor : 'white' });
var tb1 = Titanium.UI.createTabbedBar({ labels : ['Sports', 'Map', 'Books', 'Contact'], backgroundColor : '#336699', top : 0, style : Titanium.UI.iPhone.SystemButtonStyle.BAR, height : 40, width : '100%', index : 1, }); win.add(tb1);
var newWin = Ti.UI.createWindow({ url : 'book.js' });
tb1.addEventListener('click', function(e) { if(e.index == 0) { var newWin = Ti.UI.createWindow({ url : 'book.js', top : 41 }); newWin.open(); } if(e.index == 1) { var newWin = Ti.UI.createWindow({ url : 'geo.js', top : 41 }); newWin.open(); } if(e.index == 2) { var newWin = Ti.UI.createWindow({ url : 'map.js', top : 41 }); newWin.open(); } if(e.index == 3) { var newWin = Ti.UI.createWindow({ url : 'galary.js', top : 41 }); newWin.open(); } })
win.open();
return win; };
module.exports = tibook;
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Now I get a script errro and it says it can't find vairale : module at book.js
I thought the code was right, but obviously not :). all I am doing is referencing a simple screen. Any thoughts with that?
});
Thanks for your help in advance. -Paul
2 Answers
Well, first of all, you are mixing url: calls with commonJS exports.
Thats not going to work at all.
I even tried it like this as well....
function tibook() { var bookWindow = require('book'); var bookWindow = new bookWindow(); bookWindow.open(); return win; };Now i don't get an eror with this, but i still see the main screen from the app.js file. I would like to be able to pull up just a list of books that i can input there myself. thanks for your thoughts. regards, -paul
Your Answer
Think you can help? Login to answer this question!