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 ?????????
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({ title:'Back' }); backButton.addEventListener('click', function(){ win.close(); }); win.leftNavButton = backButton;
-
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?
-
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;btn.addEventListener('click',function(){});
-
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.
-
Also having this problem, want to allow people to confirm leaving the page.
No signs of a solution yet?