Titanium Community Questions & Answer Archive

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

"Back" button in title bar?

How would I generate a button in a new window's title bar with the "Back" arrow-alike aesthetic?

— asked March 12th 2010 by Brian Blakely
  • back
  • button
  • title
  • ui
0 Comments

1 Answer

  • If you open a new window with and it has a bar at the top it will have a button to the previous page automatically. You can also put a button into the bar on your own

    var back = Ti.UI.createButton({
        title: "Back",
        style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
    });
    back.addEventListener("click", function() {
        Ti.UI.currentWindow.close();
    });
    Ti.UI.currentWindow.setLeftNavButton(back);
    
    — answered March 12th 2010 by Rob Edgell
    permalink
    4 Comments
    • I know it´s three years ago you answered this, but I have search all day for a simple answer and you gave it to me. Thanks a lot for that :) Worked perfectly!

      — commented January 16th 2013 by Johanna Szepanski
    • I did this, but I don't see the back button in the title?

      — commented May 20th 2013 by Shlomo Aran
    • Hi Shlomo,

      What's your windows variable set as? If you're using CommonJS, then you can try…

      function someCoolWindow() {
        var self = Ti.UI.createWindow(...);
        var backButton = Ti.UI.createButton(...);
      
        self.leftNavButton = backButton;
      
        return self;
      }
      module.exports = someCoolWindow;
      

      — commented May 20th 2013 by Paul Nelson
    • If you have just a .js file and are using say

      win
      

      as your window variable, then you can do

      win.leftNavButton = backButton
      

      — commented May 20th 2013 by Paul Nelson
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.