Tuesday, February 03, 2009

forcing repaint DOM in IE6 and IE7?

I have loop that makes server-side Ajax calls on each iteration, and returns data. This could be 50 iterations, 500, 5000, whatever. Upon each iteration, I update that particular row with a server-side response (i.e. "success" or "fail"), and then update the total count processed ("26 out of 432 processed"). -- I update the innerHTML of a div or span, and another div showing the total number of records processed (at the end of an iteration, or in the onComplete callback handler of the Ajax.Request). That is all working perfectly fine... in Firefox, Safari, and every other browser except IE6 and IE7.

I have tried IE hacks such as adding a class to the div, and dropping a class from the div, adding and dropping child nodes from the div, etc -- to attempt to force IE to repaint, I have tried waiting a small interval, to no avail. If you pop up an alert("hai"); at the end of the iteration, the the IE6 and IE7 DOM will repaint with the updated values. (btw, how dumb is that?)

Does anybody have any tried and true ways to make IE6 or IE7 repaint a particular DOM element in these cases (without obviously popping an alert)? It works flawlessly in Firefox. I know IE is a steaming pile, but just wondering if anyone has had any success with a hack that works here.

6 comments:

metric152 said...

What does your code look like?

Mark Holton said...

metric152, here you go:
http://gist.github.com/57817

Mark Holton said...

it's grabbing all the data properly, so I won't bore you with the markup... just updating the status of the processing results ...no effect in IE6 or IE7... doesn't update:

// increment progress bar:
rows_processed += 1;
bar_val = bar_val + inc_val;
setProgressBar(bar_val);
$('prg_processed').innerHTML = rows_processed;

metric152 said...

Just for S's and G's try using the document.getElementById method and see if that will make it update.

Mark Holton said...

Why should that make any difference? It's the same method as $

Unknown said...

just linked this article on my facebook account. it’s a very interesting article for all.


Mobile Applications Development