Executing JavaScript on subwindow components

There are other ways, I’m sure, and I’m not totally sure this will work - but if it does, it’s a pretty quick minor modification to what you’re already doing:
You might be able to get away with just wrapping your javascript code in a setTimeout(,0) - using 0 for the timeout causes it to execute immediately when the current ‘thread’ (i.e rendering) is done.

Worth a shot, maybe?

Best Regards,
Marc