caleywoods
5 Sep 2012, 12:00 PM
I have an issue where I'm iterating over an array of selected items from an Ext.grid.Panel using Ext.Array.each(). Inside of Ext.Array.each I am doing an Ext.Ajax.request to determine whether or not each selected item meets the business criterion and then appropriately setting the "dirty" attribute of the record.
You can see my example code here: https://gist.github.com/a83c8a5f10a5fb6fad09
T (https://gist.github.com/a83c8a5f10a5fb6fad09)he issue I have is that since Ext.Ajax.request() is asynchronous the call returns before the records dirty attribute can be flipped to false so my store.sync() executes and the record is modified in the database when it shouldn't be.
How can I cause Ext.Ajax to either block and wait or what is the better solution to this problem? The URL that is called with the ajax request returns true or false for the record depending on if it meets the criterion or not and my if statement on line #23 handles that response logic. If a true is received from the ajax call "data" will be a bool (true) and vice versa.
You can see my example code here: https://gist.github.com/a83c8a5f10a5fb6fad09
T (https://gist.github.com/a83c8a5f10a5fb6fad09)he issue I have is that since Ext.Ajax.request() is asynchronous the call returns before the records dirty attribute can be flipped to false so my store.sync() executes and the record is modified in the database when it shouldn't be.
How can I cause Ext.Ajax to either block and wait or what is the better solution to this problem? The URL that is called with the ajax request returns true or false for the record depending on if it meets the criterion or not and my if statement on line #23 handles that response logic. If a true is received from the ajax call "data" will be a bool (true) and vice versa.