M69
M69

Reputation: 506

Sencha Touch MVC load store

I have an MVC app that I have been working on but I seem to be missing some fundamentals with namespaces and accessing objects correctly. I don't understand how to load my store when the index method is called. In my model, autoload is false and I am using the same code that I have used in other apps (non MVC) but to no avail. Any thoughts?

This is my app.js:

Ext.regApplication({
    name: 'MVC',
    defaultUrl: 'Home/index',
    launch: function(){
        console.log("Launching");
        this.viewport = new MVC.views.Viewport();

    }
});

This is my controller:

Ext.regController('Update', {

    // index action
    index: function(){
        if(networkStatus()==true){
            console.log("Checking for Updated Config: " + CONFIG_URL);
            MVC.stores.Updates.load();//Uncaught TypeError: Cannot read property 'Updates' of undefined
        }
        if ( ! this.indexView){
            this.indexView = this.render({
                xtype: 'UpdateIndex',
            });
        }
        this.application.viewport.setActiveItem(this.indexView);
    },
});

This is my Model:

Ext.regModel('UpdateModel', {
    fields: [
        {name: 'id'},
        {name: 'version'},
        {name: 'date'},
        {name: 'md5'},
        {name: 'manifest-doc'},
        {name: 'manifest-image'}
    ]
});

This is my Store:

Ext.regStore('Updates', {
    model: 'UpdateModel',
    storeId: 'Updates',
    autoLoad: false,
    proxy: {
        type: 'ajax',
        url: 'app/data/config.min.json',
        reader: new Ext.data.JsonReader({
            root: 'config',
        }),
        timeout: 6000,
        listeners: {
            exception:function () {
                console.log("Update Failed");
            }
        }
    }
});

Upvotes: 0

Views: 6119

Answers (2)

nisc
nisc

Reputation: 4400

Try

var updatesStore = Ext.getStore("Updates");

http://docs.sencha.com/touch/2-0/#!/api/Ext-method-getStore

Upvotes: 2

ilija139
ilija139

Reputation: 2974

What is MVC? It should be the name of the app i.e.

    Ext.regApplication({
      name: 'MVC',

Upvotes: 0

Related Questions