Results 1 to 4 of 4

Thread: getters return undefined after native install

  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    47
    Answers
    3

    Default Answered: getters return undefined after native install

    Hi,

    I have an app that runs just fine inside my Chrome browser.
    After creating a native package and testing it on my Android tablet however, I receive errors like:

    Uncaught TypeError: Cannot call method 'reset' of undefined.

    These errors show that my 'view-getters' return undefined inside my controller.
    Like I said the code worked fine in my browser, but after making a native installation I got those errors.
    Anyone experienced this before?

    My controller's refs section:

    Code:
    Ext.define('BcTouch.controller.HomeViewController',
    {
        extend: 'Ext.app.Controller',
    
    
        config:
        {
            refs:
            {
                loginView: 'loginView',
                homeView: 'homeView',
                notificationsView: 'notificationsView',
                resultsView: 'resultsView'
            },
            control:
            {
                homeView:
                {
                    onTileTapCommand: 'onTileTapCommand',
                    onSearchInputCommand: 'onSearchInputCommand',
                    onLogoutButtonTapCommand: 'onLogoutButtonTapCommand'
                }
            }
        },
    Inside this file errors occur on code like this:

    Code:
       bindResultModelData: function (record)
        {
                ......
                this.getResultsView().down('resultsList').select(0); // cannot call method 'down' of undefined

  2. Took me a long time to figure this one out.

    In app.js I used this line of code to add my views to the viewport:

    Code:
    Ext.Viewport.add(loginView, homeView, resultsView, notificationsView);
    The view's stores are only loaded when the view becomes visible, but at least I have the views in place when the app starts, and I can slide from one view to another.
    This worked fine inside the Chrome browser, however when I created a build and ran the apk file on my Android tablet I noticed that there was no reference to my views anymore.

    The solution was to add the views one by one like so:

    Code:
     
    Ext.Viewport.add(loginView);
    Ext.Viewport.add(homeView);
    Ext.Viewport.add(resultsView);
    Ext.Viewport.add(notificationsView);
    Still feel a bit frustrated by this issue, because the solution didn't come logically and it took precious time to figure this out.
    Hopes it helps out other people with the same problem though.

  3. #2
    Sencha Premium User mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    693
    Answers
    21

    Default

    You have to make sure that you have an instance of the class resultsView when you try to access it.
    Seems you hook into to early in the lifecycle. One option can be to use the autoCreate option in the refs section if this make se

  4. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    47
    Answers
    3

    Default

    tnx,
    however the app works fine .... inside the browser.
    So the flow is correct, it only seems that after building the native version there is some sencha core missing.
    The core part that creates the getters for those refs.

  5. #4
    Sencha User
    Join Date
    Feb 2013
    Posts
    47
    Answers
    3

    Default

    Took me a long time to figure this one out.

    In app.js I used this line of code to add my views to the viewport:

    Code:
    Ext.Viewport.add(loginView, homeView, resultsView, notificationsView);
    The view's stores are only loaded when the view becomes visible, but at least I have the views in place when the app starts, and I can slide from one view to another.
    This worked fine inside the Chrome browser, however when I created a build and ran the apk file on my Android tablet I noticed that there was no reference to my views anymore.

    The solution was to add the views one by one like so:

    Code:
     
    Ext.Viewport.add(loginView);
    Ext.Viewport.add(homeView);
    Ext.Viewport.add(resultsView);
    Ext.Viewport.add(notificationsView);
    Still feel a bit frustrated by this issue, because the solution didn't come logically and it took precious time to figure this out.
    Hopes it helps out other people with the same problem though.

Posting Permissions

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