PDA

View Full Version : Abort previous LoadableDataModel.loadPage calls



kalebwalton
5 Jan 2007, 9:25 AM
When making multiple calls to loadPage (i.e. a user clicks twic) the previous call should be aborted before the next one is made to avoid a race condition where the second call returns before the first and when the first call returns it overwrites the second call's data.

kalebwalton
5 Jan 2007, 9:36 AM
Looks like it was one of those things that just didn't make it in as it only takes a few small changes to get it to work (copied the methods from another yui-ext object that already had them). I didn't capture it below but I also had to add "this.abort();" to the second line of the load method so it would abort the previous on every load.




YAHOO.ext.grid.LoadableDataModel.prototype.isLoading = function(){
return this.transId ? true : false;
};

YAHOO.ext.grid.LoadableDataModel.prototype.abort = function(){
if(this.isLoading()){
YAHOO.util.Connect.abort(this.transId);
}
};

jack.slocum
5 Jan 2007, 9:49 AM
Thanks, I added it.