jsfiddle上使用/ echo/json的Ext.view.View的简单示例

问题描述:

我无法弄清楚我的代码在jsfiddle上出了什么问题。我试图创建一个减少文件与Ext-JS的错误。这是我正在使用的代码。 http://jsfiddle.net/qGBYT/jsfiddle上使用/ echo/json的Ext.view.View的简单示例

Ext.define('test.Model', { 
    extend: 'Ext.data.Model', 
    fields: ['id'], 
    idProperty: 'id', 
    proxy: { 
     // Have also tried 'ajax' 
     type: 'rest', 
     url: '/echo/json',   
     reader: { 
      type: 'json', 
      root: 'records' 
     } 
    } 
}, 

function(){ 
    var store = new Ext.data.Store({model:'test.Model'}); 
    var list = new Ext.view.View({ 
     itemTpl: '<div>{id}</div>', 
     renderTo: Ext.getBody(), 
     width: 300, 
     height: 500, 
     store: store 
    }); 

    store.load({params: {json: '{"records":[{"id":1}]'}}); 

}); 

该错误消息我得到的是

Uncaught TypeError: Cannot read property 'type' of undefined 

这是由上面的代码

+0

你可以发布一个链接到你的小提琴吗? – sha

+0

D'oh http://jsfiddle.net/qGBYT/ –

+0

对不起...我试图从回调之外移动你的商店创建代码,它工作正常 - http://jsfiddle.net/qGBYT/11/ – sha

的第一行我试图从回调外移到您的商店创建代码引起的它工作得很好 -

http://jsfiddle.net/qGBYT/11

不知道为什么它不喜欢原来的一个