PDA

View Full Version : Grid + ajax timing issues



wwwald
9 Nov 2011, 8:58 AM
Hi all,

Using Extjs 3.2.1 here, because of a GeoExt requirement.

I have a Grid with checkboxes (using CheckboxSelectionModel). The checkbox selection handler fetches a data record from the server through an Ajax request, and then extends an in-memory array with that record.
The checkbox UNselection handler removes that same record from the in-memory array.

Now, the problem: if I click twice very fast on a checkbox, then the Ajax call from the select handler hasn't returned when the unselect handler is called, and my in-memory array does not contain the requested data record yet.
Result: the unselect handler does not remove anything from the array (since the record isn't there yet), and *afterwards* the select handler Ajax call finally finishes and puts in the record anyway.
Conclusion: checkbox is unchecked, but the record is in my array anyway.

How do I handle this in an elegant way? Is there some way to get a hold of the original Ajax call's status in the unselect handler?

Thanks for any advice,

mitchellsimoens
10 Nov 2011, 5:30 AM
You can buffer event listeners so that the listener will only listen to one firing of that event for x number of milliseconds.