2

I have written a simple global function at the app.js level of my sencha touch 2.1 application. Now, based on the clues found here on stack and from other sources, all that i have to do to call it from everywhere is something like

TimeMobile.app.myGlobalFunction(params);

the point is, it does not work and i get the error:

Uncaught TypeError: Object [object Object] has no method 'getLocalLoggedUserDetails'

I tried to call the launch() function instead and that is working. This is puzzling me more than before because at this point it's not a syntax problem.

I call the global function like this:

var LoggedUserDetails = TimeMobile.app.getLoggedUserDetails(true);

and my app.js is defined like this:

Ext.Loader.setConfig({
    enabled: true
});

Ext.application({
    models: [
        'LoginResponse'
    ],
    stores: [
        'LoginStore',
        'PlannedActivityListStore',
        'RemoteUserDetailsStore',
        'LocalUserDetailsStore'
    ],
    views: [
        'LoginView'
    ],
    name: 'TimeMobile',
    controllers: [
        'ctlLogin',
        'ctlPlannedActivities'
    ],

    launch: function() {
        //this.TimeMobile =this;
        TimeMobile.app.LoggedUser ='';
        TimeMobile.app.LoggedUserPsw ='';
        TimeMobile.app.AnagId = 'CTEL';
        TimeMobile.app.CurrentDate = new Date().toISOString();
        TimeMobile.app.LoggedUserDetails = TimeMobile.model.mdlUserDetails();

        Ext.create('TimeMobile.view.LoginView', {fullscreen: true});
    },

    getLoggedUserDetails: function(enabled) {
        if (enabled)
        {
            //var store= TimeMobile.app.LocalUserDetailsStore();
            //return store.getAt(0);
            console.log('called');
        }
        else
        {
            return null;
        }
    }

});

When I call getLoadedUserDetails with the syntax TimeMobile.app.getLoadedUserDetails(true); I get the error previously mentioned. TimeMobile.getLoadedUserDetails(true); does not work either.

Any suggestions?

vaitrafra
  • 666
  • 3
  • 15
  • Maybe you can take a look with the article. [Call controller's function from another controller / Share data between controllers][1] [1]: http://stackoverflow.com/a/10672241/1034986 – 456qwe123asd Sep 13 '13 at 03:03

1 Answers1

0

Chrome caching were preventing my app.js to be downloaded upon application refresh.

My bad.

To disable chrome caching, go to the console, click on the gear icon on the bottom-right corner and find the "disable cache" checkbox in the "General" tab.

P.S. for the ones who -1ed without sayng anything about the question, have fun (on my profile you can find alot of questions or answer where you can have a bit more fun).

vaitrafra
  • 666
  • 3
  • 15