onAfterEventDisplay to simulate a click

I added the following code to simulate a click when I run showEvent. Specifically, I want to show the quickview window if it’s active, and I want to zoom to the event in map view.

scheduler.attachEvent("onAfterEventDisplay", function(id,view){ scheduler.callEvent("onClick", [id, scheduler.getEvent(id)]); return true; }); (shows below error)

When I run this code, I get an error “Uncaught TypeError: Cannot read property ‘lat’ of undefined(…)” when I’m in map view, or a similar “Uncaught TypeError: Cannot read property ‘readonly’ of undefined(…)” when I’m in week view.

Strangely, if I issue the callEvent right from the browser console, it works exactly as expected - shows the quickview and shows the event on the map.

scheduler.callEvent("onClick", [url['id'], scheduler.getEvent(url['id'])]); (works)