uberedit (4) [Avatar] Offline
Hi Bear, Forum Folks:

I'm wrestling with a ridiculous problem in IE6. I render a page full of data on the server-side, and then iterate through the results (rows of an HTML table) on the client side, updating each row in sequence with the results of an AJAX call on each row. (I don't want to use .each(), don't ask...)

IE6 will not show anything on the client side until all of the code in the document.ready() block completes. In the code below you'll see it's reproducible without the AJAX db calls: take a table of 100 rows, and when the document is ready, iterate through the TR collection and replace the text node in each TD. IE6 won't show a thing until the jQuery code is finished executing.

Here's the test case:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready( function() {
var totalRows = $('table tr').size();
for (var i=0; i<totalRows; i++) { >
var currentRow=$('table tr').eq(i);
var cellTarget = currentRow.children(0);
cellTarget.html('and after');

... repeat 97 more times ...

Here's the nutty part: put an alert ('hello'); after updating the TD text node and as the modal alert box pops up you can watch the rendered table underneath updating as it iterates through the row. I've tried using various sleep functions after the text node update to no avail -- it doesn't seem to have an effect other than slowing down the overall execution time. I've tried moving the script blocks to the end of the file and that doesn't seem to fix the issue either.

Any ideas?
bear.bibeault (675) [Avatar] Offline
Re: Strange delay in DOM updating in IE
IE's renderer, especially the one in IE6, isn't the sharpest tack in the box. I suspect -- what you don't want to hear -- is that there will be no work-around that will make it snappier.

Is this not something you can also handle on the server?
uberedit (4) [Avatar] Offline
Re: Strange delay in DOM updating in IE

I was hopeful that I could implement some sort of delay mechanism to allow the renderer to catch up since throwing the alert seems to do the trick, but nothing I've tried (all variations on a sleep routine) seems to work. I was very surprised to see that even IE8 struggles with this.

I can do it server-side, I was just hoping to do it this way for presentation purposes.

Thanks for the quick response!
bear.bibeault (675) [Avatar] Offline
Re: Strange delay in DOM updating in IE
Two thoughts:

>some sort of delay mechanism
have you tried a setTimeout?

If you've got to bend over this much to get something to work, even if you get it to work, it's gonna be fragile and likely to cause problems at the worst possible times. It's a sign that another approach need be considered.