Allow widgets to be constructed from Javascript

Also fixes a bug in the comm manager.
Can you describe the use of `init_state_callback`?