changed js event registers to use delegate