Titanium Community Questions & Answer Archive

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

how to add event listener to back button in the navigation group ?

Back buttons in the navigation group created automatically, and i've no control over it, any means i can add event listener on it ?????????

— asked August 28th 2010 by mostafa farghaly
  • event
  • navigation
  • window

6 Answers

  • Hey Guys,

    Not sure if this will help anyone but this is what I used to do the same thing in a tabGroup, maybe it can be useful inside of a navGroup as well?

    var backButton = Ti.UI.createButton({
    backButton.addEventListener('click', function(){
    win.leftNavButton = backButton;
    — answered November 2nd 2010 by Michael Fogg
    1 Comment
    • This works :-)

      — commented September 7th 2012 by nesarajan mani
  • If anyone is still looking for an answer – I solved this by adding blur event listener to the window. It worked for me, but depending on what exactly you need to do this may not be the best option. What Michael is suggesting works, but it makes the button rectangular, and I wanted to keep the 'left arrow' type button and not deal with images.

    so something like this

    my_win.addEventListener('blur', function() {
        //do stuff
  • Having same problem. Any luck finding a solution?

    — answered September 23rd 2010 by Kelly Redd
  • You can create a button (may be with system button style) and assign it to window's leftNavButton property. You can add an event listener to the button created above.

    var btn = Ti.UI.createButton({});
    win.leftNavButton = btn;


    — answered September 23rd 2010 by Sravan Vinjamuri
  • It might be possible to add an event listener to the default back button:

    Ti.UI.currentWindow.leftNavButton.addEventListener('click', function(e)
        // custom code

    Not tested.

    Otherwise Sravan's solution (with code to manually close the window) should be fine.

    — answered September 24th 2010 by James K
    1 Comment
    • This is wrong unless you do define and assign that button.

      — commented October 12th 2011 by Zhenya Kogan
  • Also having this problem, want to allow people to confirm leaving the page.

    No signs of a solution yet?

    — answered October 7th 2010 by Dan Matthews
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.