adube
1 Mar 2012, 6:17 AM
Hi,
In Ext 3.x, I used to be able to do this within a class :
var foo = "bar";
store.each(function(record, index, records) {
alert(foo); // alerts "bar"
}, this);
but in Ext 4 it doesn't seem to work anymore : foo is undefined. I know I could do the following :
var foo = "bar";
store.each(function(record, index, records) {
alert(this.foo); // alerts "bar"
}, {
'me': this,
'foo': foo
});
but I wonder if there's something I'm missing. What would be the correct way to have access to foo within the function given as argument to the each method ?
Many thanks,
Alexandre
In Ext 3.x, I used to be able to do this within a class :
var foo = "bar";
store.each(function(record, index, records) {
alert(foo); // alerts "bar"
}, this);
but in Ext 4 it doesn't seem to work anymore : foo is undefined. I know I could do the following :
var foo = "bar";
store.each(function(record, index, records) {
alert(this.foo); // alerts "bar"
}, {
'me': this,
'foo': foo
});
but I wonder if there's something I'm missing. What would be the correct way to have access to foo within the function given as argument to the each method ?
Many thanks,
Alexandre