mardi 22 avril 2014

Application instance is null while setting Global listener in initialize()

I should preface by saying this only happens in a production build:

I have an event listener that I have setup in my container class in the initialize function. In a production build, an error is thrown telling me that:


App.app is 'undefined and is 'not an object'.


If I wrap this event listener in a setTimeout(0), then all is fine. This makes sense because in a production build everything is minified so the app initializes quicker and I'm thinking that myApp.app seems not to be instantiated at the time I reference it to set my listener. Do I have to wrap all these type of listeners in setTimeouts() or is there another workaround?



Code:



Ext.define('myApp.view.AbsSlidingContainer', {
extend: 'Ext.Container',
xtype: 'absSlidingContainer',
initialize:function() {
myApp.app.on({
slidingPanelScroll: this.scrollToTop,
scope: this
});
}
...
}




Aucun commentaire:

Enregistrer un commentaire