View Full Version : [CLOSED]Model.load success callback params

16 Feb 2011, 8:52 AM
According to Ext4 preview documentation, we should get the user object as parameter to success callback of Model.load method:

//get a reference to the User model class
var User = Ext.ModelMgr.getModel('User');

//Uses the configured RestProxy to make a GET request to /users/123
User.load(123, {
success: function(user) {
console.log(user.getId()); //logs 123

However, if you run the above example you get an undefined user variable.

17 Feb 2011, 6:34 AM
Check out my post on this thread (http://www.sencha.com/forum/showthread.php?124228-Data-package-broken&p=572066#post572065)

17 Feb 2011, 9:25 AM
Thank you Pandaxia,

I've read your post and that entire thread (which I found quite entertaining).
I know that load can take a second operation parameter, I just didn't need it in the test above.

Anyway, I've rebuilt my test case and the example works perfectly if the server responds with:

"id": 123,
"name": "Name of user 123",
"email": "anemailaddress@gmail.com"

In other words even if you're just trying to load a single entity, it still must be placed inside an array. Thought I should mention this because others may run into the same issue.

Still, I was wondering, is this the intended behavior or will it be changed before the release?