fix javascript event handlers so they don't get reregistered repeatedly