3

I'm very new to Sencha Architect 3.0, I want to set a MyApp.globals variable(initiated at launch method) as the parameter of my store. Like so:

Ext.define('MyApp.store.myCustomer', {
    extend: 'Ext.data.Store',

requires: [
    'MyApp.model.Customer',
    'Ext.data.proxy.Ajax',
    'Ext.data.reader.Json'
],

config: {
    model: 'MyApp.model.Customer',
    storeId: 'myCustomer',
    proxy: {
        type: 'ajax',
        //global variable as parameter
        extraParams: {
            salesman: MyApp.globals.Salesman
        },

        url: 'http://localhost:96/OrdApplication/customer_list.php',
        reader: {
            type: 'json',
            rootProperty: 'items'
        }
    }
}
});

This is my launch method

launch: function() {

        MyApp.globals = {
           count: 1,
            Salesman :0

        };


        Ext.create('MyApp.view.MainView', {fullscreen: true});
    }

});

Although this store is not bound to load with anything on launch,neither with the first view, but its still seems to be loading as i'm getting the following error on launch:

Uncaught TypeError: Cannot read property 'Salesman' of undefined sencha-touch.js:8619 Uncaught Error: The following classes are not declared even if their files have been loaded: 'MyApp.store.myCustomer'.

how do I handle this issue of not having the store loaded before the declaration of variable takes place. In fact it would be great if someone could tell me to load a store dynamically on button press and fill selectfield with it.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Sabri
  • 189
  • 1
  • 1
  • 13
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). BTW, it's "Thanks in advance", not "Thanks in advanced". – John Saunders Jan 28 '15 at 20:22
  • Alright Saunders, I will be careful from next time. And it must have been a typo. – Sabri Jan 28 '15 at 21:26
  • @RobSchmuecker , do I have to add it manually from adding Functions options or will it be added like the launch event ? I have the option to add init function in controller though ! Not having one in Application – Sabri Jan 29 '15 at 10:53
  • I did as you said added an init function. First it gives me information that this init is overriding a parent function, which I dont know where to add from. And second its still giving me the same error if I try to use the global variable after putting it in the init function I created – Sabri Jan 29 '15 at 11:06
  • Hi Sabri, I also just noticed that. Will get back to you soon, gonna delete my false comments. – Rob Schmuecker Jan 29 '15 at 11:36
  • 1
    Have a look at this http://stackoverflow.com/questions/16074155/global-variable-sencha-touch-2-1 – Rob Schmuecker Jan 29 '15 at 12:10
  • Okay I will have a look. – Sabri Jan 29 '15 at 12:47

0 Answers0