I'm trying to implementing Lazy loading in ExtJS 4 like this example: http://dev.sencha.com/deploy/ext-4.0.0/examples/data/associations.html using this Code:
/* 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"}]
but the returned Posts-Store is always empty (0 Records). You can check my JSFiddle here: http://jsfiddle.net/lenoxDoe/n6Xbw/2/
Any advice would be helpful.