Results 1 to 2 of 2

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

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    New Jersey
    Posts
    116
    Answers
    6

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

    I should preface by saying this only happens in a production build and I often come across errors being thrown that are in a production build and not the development build --- is there something I can do to avoid that?

    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:

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

    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. Is there workaround?

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

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,108
    Answers
    342

    Default

    Probably a timing issue. When is the view instantiated? May have to add the listener within the launch method or define on Ext.application.
    Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services [email protected]

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •