View Full Version : Uncaught TypeError: Cannot call method 'indexOf' of undefined

17 Aug 2011, 7:44 PM
Example source here: http://andrewpeace.com/testapp/

(http://andrewpeace.com/testapp/)Somehow Ext.gesture.Manager's `addEventListener` method is getting called before its `init` method, resulting in this.targets being undefined.

This results in the error: "Uncaught TypeError: Cannot call method 'indexOf' of undefined"

The error doesn't *always* happen. You may need to refresh the example a few times in order to see it.

I can't figure out for the life of me what I am doing wrong in my source. Any help is greatly appreciated.

18 Aug 2011, 8:58 AM
I solved this problem.

I had defined an action called `init` in one of my controllers. Turns out this causes the action to run as soon as the controller is instantiated, before the app's `launch` event has been fired. Renaming the action made everything run as expected.

I can't find reference to the special behavior of the `init` action in the Sencha Touch doc. It would be good to put this in there!