I have it fixed. The fix I believe is a trick, but I didn't know another way.
I took approach 3, as mentioned above. You have a timeout from 1 ms, and the counter increments in that timeout, i.e.
setTimeout(function() { counter++; }, 1);
I have one more counter of my verification code to delay it for 1 ms and check the condition if the counter is equal to all available controls, if not check again until the condition is false. Otherwise, continue.
function validate() { if (counter != total number of frames) { setTimeout(function() { validate(); }, 1); return false; } ... }
Thanks to everyone for your materials, it helped a lot. I hope this will be the last solution for such issues.
source share