sourcebitsllc/chocolatechip-ui — pull request #29 by mattgoldspink (2013-12-26 17:09:32+00:00)
Title: Fixing setTimeout of $.UIGoToArticle to be 1ms

There is a race condition whereby 2 $.UIGoToArticle invocations may be made in swift succession - for example I do the following:

- User fills in form and taps submit button
- $.UIGoToArticle - show a loading screen
- make an AJAX request to a server to kick of a query
- On return of AJAX request call $.UIGoToArticle to show results

If the results return within 500ms (some queries are super quick on my server because they're cached) the second call is ignored because $.isNavigating is still set to true. I don't see why 500ms is really needed as it is a fair assumption that by the end of this function the css classes in the DOM have been written through and hence the browser will have made the transition, therefore using a setTimeout of 1 should allow the browser to do the actual UI updates if needed and conclude that navigating is complete.