I'm trying to get a handle on using the MVC paradigm with ExtJS (which isn't easy for those of us who originally learning programming with Fortran II). I've been working with the "Getting up and running" documentation and have run into some conceptual problems with a bit of the code.
The first issue is that it appears to be loading data into MyApp.model.User. The problem is that this has been defined, but no instance of this type of object has been created. I thought you needed an instance before you could load. Or does this simply create an instance automatically when you try to load data into it and remove the need for a Ext.create call?
Looking for some very basic insight
Code:
// Loads User with ID 1 and related posts and comments
// using User's Proxy
MyApp.model.User.load(1, {
callback: function(user) {
console.log('User: ' + user.get('name'));
user.posts(function(posts){
posts.each(function(post) {
console.log('Post: ' + post.get('title'));
});
});
}
});
The first issue is that it appears to be loading data into MyApp.model.User. The problem is that this has been defined, but no instance of this type of object has been created. I thought you needed an instance before you could load. Or does this simply create an instance automatically when you try to load data into it and remove the need for a Ext.create call?
Second, the comment implies that the first argument, 1, tells the load function to load data for the user with ID of 1. I haven't been able to find any documentation for any load function that discusses any argument that does this. Worse, if I try to change the value to 2, it throws an error rather than get the data for user 2.
Finally, I would assume that this model must have an internal store to hold the data. But stores in turn need an internal model to structure the data they hold. This all seems very circular. Am I missing something very basic?
Looking for some very basic insight
Aucun commentaire:
Enregistrer un commentaire