Create an about button in titlebar
Hiya,
Trying to get a button working in the titlebar is becoming a little difficult. At present the button opens when clicked (calls a window with a webview), and closes when an html button is clicked. But only once. The issue is that after the window is closed, the titlebar button seemingly wont reopen the window…
This is probably a simple error, but one i'm having difficulty finding an answer to.
My app.js:
var infoBtn = Titanium.UI.createButton({
title:'Info'
});
// ABOUT
var win0 = Titanium.UI.createWindow();
var webview0 = Titanium.UI.createWebView({url: 'about.html'});
infoBtn.addEventListener('click', function() { win0.open(); });
Ti.App.addEventListener('closeAbout', function() { win0.close(); });
win0.add(webview0);
win0.hideNavBar();
My about.html
<head>
<script type="text/javascript" charset="utf-8">
function closeAboutBtn() {
Ti.App.fireEvent('closeAbout');
}
</script>
</head>
<body>
<a href="#" class="btn" onClick="closeAboutBtn(); return false;">Return to App</a>
</body>
1 Answer
-
Accepted Answer
Try this:
var infoBtn = Titanium.UI.createButton({ title:'Info' }); // ABOUT var win0=false; infoBtn.addEventListener('click', function() { win0 = Titanium.UI.createWindow(); var webview0 = Titanium.UI.createWebView({url: 'about.html'}); win0.add(webview0); win0.hideNavBar(); win0.open(); } ); Ti.App.addEventListener('closeAbout', function() { win0.close(); });