0

煎茶触摸 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()被调用,这是怎么回事?

4

1 回答 1

0

前加载必须在“配置”之外。

例子:

  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',
            }
    }
});
于 2012-11-18T15:21:25.300 回答