Onclick obj ref to context obj

Added property to link the onClick object to the context object.
Also replaced deprecated JS function calls