javascript property race condition

KarinaDallas

New Member
I have a phonegap project on iPhone and Android. The issue appears to be a race condition on the surface, but I don't understand how it happens. Users are able to click on a button which has a closure callback that sets a property of an object, and then clears the screen and loads the main menu. In code:\[code\]button.onclick = function (employee) { return function () { employee.task = "some task"; returnToMenu(); }}(employees);\[/code\]After the user is back on the main menu, they can click on a button that loads a screen which displays all the users. If an employee has that task property set, additionally formatting should be done to the button for that employee. \[code\]if (employee.task) // style the button being created for this employee\[/code\]Somehow, if one clicks fast enough, the formatting is not done. If you click back (to the main menu), and reload the screen, the formatting is now done. Given the code above, I do not see how \[code\]employee.task\[/code\] could possibly return undefined after the menu has been loaded. What's going on here?
 
Back
Top