1
votes

I am using navigation window in my app.
I want to reset variable when every time window appear.
I tried

$.win.addEventListener("focus", function(e){
    alert("window appear");
});

This is not calling. So i tried following:

$.win.addEventListener("open", function(e){
     alert("window appear");
});

But this is only call when first time it open..it is not called when screen open from back clicked.

1
Do you develop on Android only? - Giordano
No...actually i am in ios - Divyesh Savaliya
weird...focus should works. Be careful with focus + alert message, because when you close an alert, it will call the focus callback again and you will have a loop - Carlos Zinato
Console.log also not working - Divyesh Savaliya
Not console.log but Ti.API.info - Giordano

1 Answers

0
votes

Focus should work if you minimise the app or show the status bar, blur will also be triggered when the window loses focus.

It sounds like you are never closing the window or you are registering the event listeners inside another function, ensure the event listeners are defined at the top level (not in any other functions).

Console.log doesn't work very well in titanium use Ti.API.info('Alert message');