JavaScript events for custom objects