Store not syncing when sync function is overridden Sencha Touch 2.3

I'm creating an offline mode for my app and I need to override the sync function on my stores. However, when I do this the store no longer syncs even when I call this.callParent(arguments) .

Here is the overridden function:

sync: function(){
    if(appOnline){
        console.log('App is online');
        this.callParent(arguments);
    }   
    else{
        console.log('App is offline');
        var found = false;

        for(var i = 0; i < storeSyncList.length; i++){
            if(storeSyncList[i] === this){
                found = true;
                break;
            }
        }

        if(!found)
            storeSyncList.push(this);
    }   
}

Why is this.callParent(arguments) not working? When the app goes online the function is called like this:

storeSyncList[i].sync.call(storeSyncList[i],{
    scope: this,
    callback: function(records, operation, success){
        console.log('test1');
        console.log('successful sync: '(success ? 'Yes' : 'No'));
    }
});

As you can see on the call, I'm passing in the store as the this portion of sync.call() . storeSyncList[i] is the current store being synced when the app goes back online.

Does anyone know why the this.callParent(arguments) wouldn't be doing the sync when this is the store? I know it's not. When I look at the database it isn't updated and the callback function is never called. However, I know for sure that it is running the sync.call line. What's going on here?

UPDATE: After debugging line by line the call to this.callParent(arguments) is being skipped over. I cannot step into the function and it is never run, the program just passes over it as if it's not there and goes to the end of the function. Very odd. Anyone know why?

EDIT: Pastebin of whole class http://pastebin.com/WMZTh5PR sync is at the bottom.


If you need to override some object, the best way is use the option "override".

Ext.define('Airit.store.App', {
    override: 'Ext.data.Store',
    sync: function() {
       this.callParent(arguments)
       //etc
    }
});

Just use the "require" for this.

链接地址: http://www.djcxy.com/p/80028.html

上一篇: ExtJS商店添加调用既创建和销毁

下一篇: 当同步功能被重写时,存储不会同步Sencha Touch 2.3