2014-05-01 135 views
0

我試圖剛剛從代理中加載一個列表,使用休息來從服務器獲取數據。我無法弄清楚我做錯了什麼,但我沒有看到任何對Chrome的網絡通話記錄中的/餐廳的GET請求。最初我以爲也許控制器沒有被包含在內,但它就在那裏,當我在它所在的商店中添加數據時。這不是拋出任何錯誤,所以我不能調試它。我已經完成了所有可能的教程以及文檔。任何幫助或見解都非常感謝。Sencha Touch 2代理不會觸發任何請求

控制器:

Ext.define('Appetize.controller.Restaurants', { 
    extend: 'Ext.app.Controller', 

    config: { 
    models: ['Restaurant'], 
    views: [ 
     'RestaurantList', 
    ], 
    refs: { 
    }, 
    control: { } 
} 
} 

型號:

Ext.define('Appetize.model.Restaurant', { 
    extend: 'Ext.data.Model', 

    config: { 
    fields: [ 
     {name: 'id'}, 
     {name: 'name'}, 
     {name: 'delivers'}, 
     {name: 'active'} 
    ] 
    } 
}); 

店:

Ext.define('Appetize.store.Restaurants', { 
    extend: 'Ext.data.Store', 
    requires: ['Appetize.model.Restaurant'], 
    config: { 
    model: 'Appetize.model.Restaurant', 
    proxy: { 
     type: 'rest', 
     url: '/restaurants', 
     autoLoad: 'true' 
    } 
} 
}); 

查看:

Ext.define('Appetize.view.RestaurantList', { 
    extend: 'Ext.List', 
    xtype: 'restaurantListCard', 
    config: { 
    iconCls:   'home', 
    title:   'Restaurants', 
    id:    'restaurantList', 
    store:   'Restaurants', 
    onItemDisclosure: true, 
    itemTpl:   '{name}' 
    } 
}); 
+0

您尚未在控制器中指定'stores'。 –

+0

我在app.js中包含了商店。我嘗試將它添加到控制器,它沒有任何區別。如果我在商店中包含數據,它會按照預期顯示在餐館列表中。但代理似乎並不想開火。我在模型中嘗試過也沒有成功 –

回答

2

事實證明,我有autoLoad在錯誤的地方。它不應該在代理設置中。相反,它應該作爲config的一部分在代理之外。

Ext.define('Appetize.store.Restaurants', { 
    extend: 'Ext.data.Store', 
    requires: ['Appetize.model.Restaurant'], 
    config: { 
    model: 'Appetize.model.Restaurant', 
    proxy: { 
     type: 'rest', 
     url: '/restaurants', 
    }, 
    autoLoad: 'true' 
} 
});