jquery - DoEvents in JavaScript -
i have following:
$('body, a').addclass('cursor-wait'); (var i=0, l = myarray.length; < l; i++) { // tight loop here } $('body, a').removeclass('cursor-wait'); but i'm not sure cursor:wait icon showing immediately.
q: there way tell "doevents" in javascript, such know dom being updated before goes loop?
maybe using settimeout method.
here's happening:
the browser instance handling page single threaded. change dom happens right away. however, while script running, browser blocked , not able run layout manager updates page according css classes have changed. correct settimeout best way cede control layout manager , see changes on screen. don't need set delay, simple act of calling settimeout allows layout manager chance redraw page.
$('body, a').addclass('cursor-wait'); settimeout(function () { (var i=0, l = myarray.length; < l; i++) { // tight loop here } $('body, a').removeclass('cursor-wait'); });
Comments
Post a Comment