【发布时间】:2013-04-18 06:41:18
【问题描述】:
我正在尝试在 ExtJS 4 中实现延迟加载,如下例:http://dev.sencha.com/deploy/ext-4.0.0/examples/data/associations.html 使用此代码:
/* Models */
Ext.define('Post', {
extend: 'Ext.data.Model',
fields: ['title'],
proxy: {
type: 'ajax',
url: 'http://example.com/post.json'
}
});
Ext.define('User', {
extend: 'Ext.data.Model',
fields: ['name'],
hasMany: 'Post',
proxy: {
type: 'ajax',
url : 'http://example.com/user.json'
}
});
/* Load User and Posts */
User.load(1, {
success: function(user) {
var test = user.posts();
test.on('load', function(me) {
console.log(me.getCount()); /* THIS is always 0?! */
});
test.load();
}
});
/* Returned JSON Data */
/* User */
[{"name":"blalala"}]
/* Posts */
[{"title":"dfgdfgdgd"}]
但返回的 Posts-Store 始终为空(0 条记录)。你可以在这里查看我的 JSFiddle:http://jsfiddle.net/lenoxDoe/n6Xbw/2/
任何建议都会有所帮助。
【问题讨论】:
标签: javascript extjs extjs4