I know this question comes up from time to time, but 10-15 minutes of
googling hasn't produced a useful answer for me. I'm looking for the
equivalent of insert_magic_here() in:
some_element.style.color = 'red';
insert_magic_here();
some_element.style.color = 'blue';
insert_magic_here();
where insert_magic_here() will cause the updated DOM to be rendered
immediately. I need to do some animation in the middle of an event
handler (keypress). Is the basic problem that Firefox doesn't do the
on screen render until the event handler returns? Or ...? Anyway there
is quite a bit of work to do after this completes, including,
potentially, many other similar sequences of events.
If it helps, this code is intended to run only in JavaScript >= 1.7,
with Firefox as a reference platform.
I can come up with various painful ways to do this with closures and
so on but I am looking for something that won't serve as an entry in
an obfuscated Javascript contest. Also I haven't looked at generators
as a solution yet.
Your Help Is Appreciated(TM).