Gestures addEventListener does not get added a second time.
I have the following code:
win.addEventListener('focus', function(e){
Titanium.Gesture.addEventListener('orientationchange', dosomething);
});
win.addEventListener('blur', function(e){
Titanium.Gesture.removeEventListener('orientationchange', dosomething);
});
Everything works the first time I view the window, but if the window gets closed and re-opened the Titanium.Gestures.addEventListener
event does not get added a second time, and dosomething
is never called (a second time).
FYI. The focus
event always gets fired.
Is there a way to have the orientation
event only fire when you are on a certain window?
2 Answers
-
Accepted Answer
Thanks Roger, this works for me too! Great!
-
Looks like this happens in the KitchenSink App too!
I found a workaround though:
I moved the Gesture event to app.js where it only gets called once:
Ti.Gesture.addEventListener('orientationchange',function(e) { Titanium.App.fireEvent('doSomething'); });
Then in my window view I have:
win.addEventListener('focus', function(e){ Titanium.App.addEventListener('doSomething', dosomething); }); win.addEventListener('blur', function(e){ Titanium.App.removeEventListener('doSomething', dosomething); }); Hope this helps someone out there!?