PDA

View Full Version : Event registration during and after an AJAX call (for a remote store to load)



Ppecher
24 Feb 2011, 9:20 AM
1. Assuming 'load' is fired after 1 ms and the first listener registered by the computer after 2 ms. Will someFunctionB be called?
2. Assuming 'load' is fired after 800 ms and the first listener registered by the computer after 2 ms, and the second listener after 3 ms. Will someFunctionB be called for both indices?



SomeClass = Ext.Extend(SomeSuperClass,
initComponent: function () {
this['someStore'] = new Ext.data.Store({
proxy: x('y/z.asmx/s'),
reader:JSONReader([
{ name: 'g', type: 'string', mapping: 'g' },
]),
sortInfo: { field: 'g', direction: "ASC" }
});
this['someStore'].load(
{
params:
{
ID: this.config.id
}
});
for(var i = 0;i<2;i++){
this.someFunctionA(i);
}
}
someFunctionA: function(index){
this['someStore'].on("load", function() {this.someFunctionB(index);}, this);
}
someFunctionB: function(index){
var record = this['someStore'].getAt(index);
console.log(record);
}
}

Ppecher
24 Feb 2011, 9:57 AM
Im fairly confident that 1. No 2. Yes