Finally got events to work.
This seems to work for placing button and menu event handling.
This version works sometimes, so the order of execution is almost correct without any explicit delays.  The initialization of event handling must be forced to be the last thing executed.  This can probably be accomplished by waiting until the html has finished fiddling around.