uberedit (4) [Avatar] Offline
#1
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:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<head>
<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');
}

});
</script>
</head>
<body>
<table>
<tr><td>before</td></tr>
<tr><td>before</td></tr>
<tr><td>before</td></tr>
... repeat 97 more times ...
</table>
</body>
</html>

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
#2
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
#3
Re: Strange delay in DOM updating in IE
Bummer.

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
#4
Re: Strange delay in DOM updating in IE
Two thoughts:

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

2)
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.