Fixed error thrown because e.originalEvent may not exist if 'click' is triggered programmatically.