为什么不调用load()和beforeload()?

时间:2012-06-21 18:38:21

标签: javascript cordova touch extjs

Sencha Touch 2:

这是我的商店定义

var incidentsJson = loadJson();

Ext.define("App.store.EventsFeed", {
    extend: "Ext.data.Store",
    requires: ['Ext.data.proxy.JsonP'],

    config: {
            listeners: {
                    beforeload: function() {
                            console.log('before store load');
                            return true;
                    },
                    load: function(store, records) {
                            console.log(' store loaded', records);

                    }
            },
            model: 'App.model.Incident',
            autoLoad: true,
            data: incidentsJson,
            reader: {
                    type: 'json',
            }
    }
});

数据已加载但load()beforeload()没有被调用,发生了什么?

1 个答案:

答案 0 :(得分:0)

beforeload必须在“config”之外。

示例:

  var incidentsJson = loadJson();

Ext.define("App.store.EventsFeed", {
    extend: "Ext.data.Store",
    requires: ['Ext.data.proxy.JsonP'],

    listeners: {
          beforeload: function() {
               console.log('before store load');
                return true;
           },
           load: function(store, records) {
                console.log(' store loaded', records);
           }
     },

    config: {
            model: 'App.model.Incident',
            autoLoad: true,
            data: incidentsJson,
            reader: {
                    type: 'json',
            }
    }
});