PDA

View Full Version : Association getter Function returning constructor



JulianB
22 Mar 2012, 2:07 AM
Hello everyone,

here is the code I have (snippet):


this.getStore("UserStore").load(
{
callback: function(records) {
Ext.each(records, function(record) {
record.getExecutive(function(executive) {
console.log(executive);
});
});
}
}
);

I would expect to have firebug show me instances of Executive but instead it gives me
MyApp.model.Executive() for each record.

When i do (at some other point in code)


var length = records.length;
Ext.each(records, function(rec) {
rec.getExecutive(function(executive) {
console.log(executive);
length --;
if (length == 0) {
store.fireEvent('loadDependencies');
}
});
}, this);

I have the model instances that I expected inside firebug.

What is the difference / what am I doing wrong in the first snippet?

The Executive model is configured with a (as you can see in the second snippet) working ajax proxy.
(I changed the getterName to getExecutive as getMyApp.model.Executive [as the Designer suggests] is kind of wired for a getterName...)

Kind regards,
Julian

mitchellsimoens
22 Mar 2012, 7:03 AM
Odd... visually the two Ext.each should accomplish the same thing.

JulianB
22 Mar 2012, 7:29 AM
That would be what I expected them to do.
Which snippet does the "right thing", so, is returning the classes or returning the objects the correct behavior?
(I need those objects -.-)