2012-06-21 62 views
0

煎茶觸摸2:爲什麼不調用load()和beforeload()?

這是我店的定義

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()不`噸被調用,這是怎麼回事?

+0

不知道爲什麼,但顯然只存儲調用'的load()'和'beforeload()'只有當你通過代理財產​​加載數據... – Felipe

回答

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', 
      } 
    } 
}); 
相關問題