adding event handlers and binding code

for transitory events (opening/ closing)