1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    San Antonio, TX
    Posts
    93
    Answers
    4
    Vote Rating
    0
    jnotti is on a distinguished road

      0  

    Default Answered: Taking Sencha Touch Apps Offline

    Answered: Taking Sencha Touch Apps Offline


    I followed the tutorial, "Taking Sencha Touch Apps Offline" and it all works great except for trying to bind my offline store to the menuList. Here is the error I am getting, anyone have a clue as to what I am doing wrong?

    Uncaught TypeError: Cannot call method 'bindStore' of undefined:
    mApp.menuList.bindStore(mApp.offlineStore);

    In my app.js file:
    Code:
            
            // the data-bound menu list
            var menuList = viewport.menuList = new Ext.List({
                store: mApp.onlineStore,
                itemTpl: '{title}',
                allowDeselect: false,
                singleSelect: true
            });
    
            // a wrapper around the menu list
            var menu = viewport.menu = new Ext.Panel({
                items: [menuList],
                layout: 'fit',
                width: 320,
                dock: 'left'
            });
    And in my data.js file I have:
    Code:
    // remote JSON
    Ext.regModel('XPosts', {
        fields: [
            {name: 'id'},
            {name: 'type'},
            {name: 'slug'},
            {name: 'url'},
            {name: 'status'},
            {name: 'title'},
            {name: 'title_plain'},
            {name: 'content'},
            {name: 'excerpt'},
            {name: 'date'},
            {name: 'modified'}
        ]
    });
    
    mApp.onlineStore = new Ext.data.Store({
         model: 'XPosts',
         proxy: {
                type: 'scripttag',
                url : 'http://localhost/?json=get_recent_posts',
                reader: new Ext.data.JsonReader({
                    root: 'posts'
                }),
                timeout: 100,
                listeners: {
                    exception:function () {
                        console.log("onlineStore: failed");
                        mApp.menuList.bindStore(mApp.offlineStore); // This throws an error
                        mApp.offlineStore.load();
                    }
                }
            },
            autoLoad: true
    });
    
    mApp.offlineStore = new Ext.data.Store({
        model: 'XPosts',
        proxy: {
            type: 'localstorage',
            id: 'appdata',
            reader: new Ext.data.JsonReader({
                root: 'posts'
            })
        },
        autoLoad: true
    });

  2. mApp.menuList.bindStore(mApp.offlineStore);

    In my app.js file:
    Code:

    mApp.menuList = viewport.menuList = new Ext.List({ // mistake was here var menuList
    store: mApp.onlineStore,
    itemTpl: '{title}',
    allowDeselect: false,
    singleSelect: true });

    var menu = viewport.menu = new Ext.Panel({
    items: [menuList],
    layout: 'fit',
    width: 320,
    dock: 'left'});


    Copy this and run you will not get any error

  3. #2
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    San Antonio, TX
    Posts
    93
    Answers
    4
    Vote Rating
    0
    jnotti is on a distinguished road

      0  

    Default


    I think the issue is not binding the store to the menuList but rather, accessing it properly from another file.

    Within the launch sequence, menuList has a listener bound to it and it works as you would expect. My issue then becomes how to properly access the menuList. I've tried all the namespaces you would think of, mApp, app, this - of which nothing works.

    I realize that there is nothing defined for what I am calling so how do I access it!

    Cannot call method 'bindStore' of undefined

  4. #3
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    San Antonio, TX
    Posts
    93
    Answers
    4
    Vote Rating
    0
    jnotti is on a distinguished road

      0  

    Exclamation


    BUMP!

    Seriously? No one has any input on this?

  5. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    15
    Answers
    3
    Vote Rating
    0
    sangampandey is on a distinguished road

      0  

    Default Its was just a refrence mistake

    Its was just a refrence mistake


    mApp.menuList.bindStore(mApp.offlineStore);

    In my app.js file:
    Code:

    mApp.menuList = viewport.menuList = new Ext.List({ // mistake was here var menuList
    store: mApp.onlineStore,
    itemTpl: '{title}',
    allowDeselect: false,
    singleSelect: true });

    var menu = viewport.menu = new Ext.Panel({
    items: [menuList],
    layout: 'fit',
    width: 320,
    dock: 'left'});


    Copy this and run you will not get any error

Thread Participants: 1

Tags for this Thread