Reputation: 29543
I am running a loop within a click event handler doing the following:
$("<li> + data + </li>").appendTo($("#results"))
The problem is, that the DOM is not refreshed until the loop has terminated. Running the loop for 100 iterations this takes too long, I would like to give a result every time I computed one.
How can I force the DOM to be refreshed?
Upvotes: 4
Views: 3591
Reputation: 26183
If you are in a browser that supports it, workers are ideal for this situation.
If not, use setTimeout
after each computation to break the callstack and allow the browser to use time on rendering.
Upvotes: 4