Reputation: 3462
if I have
$("a#foo").click();
$("a#bar").click();
dostuff();
and both have click handlers attached which do different things..is it guaranteed that bar's click handler will only execute after foo's completes? or are they dispatched asyncronously
similarly..will dostuff() only execute after foo and bar's click handlers complete?
Upvotes: 0
Views: 149
Reputation: 8999
The Javascript execution model in the browser is single threaded (by and large), so there is no asynchronous dispatch going on anywhere outside stuff like the HttpXmlRequest.
So the foo click() function will return before bar click() is called, which will return before doStuff() is called.
Upvotes: 1
Reputation: 115420
It depends on what foo does (You could technically set up foo to fire events using setTimeout which could fire after the method completes), but yes bar should fire after foo completes.
Upvotes: 1