Appcelerator call function everytime window open

788 Views Asked by At

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

There are 1 best solutions below

7
On

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');