Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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>
— asked November 3rd 2010 by Glen McPherson
  • button
  • createwindow
  • iphone
  • titlebar
  • webview
0 Comments

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(); 
    });
    
    — answered November 3rd 2010 by Peter Griffin
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.