[GIS] Override infowindow Zoom To function or fire second event using ArcGIS JavaScript API

arcgis-javascript-apiinfowindowjavascript

The Popup of ArcGIS JavaScript API has a 'Zoom To' link on it that zooms you 4 levels closer to the linked feature.

I'd like to fire another event after the default zoom to function executes.

Here is the link in the HTML.

<div class="actionsPane">
  <div class="actionList">
    <a class="action zoomTo" href="javascript:void(0);">Zoom to</a>
  </div>
</div>

I'm able to add a function to the Zoom To click with jQuery like this:

$('.action.zoomTo').click(function() {alert('Clicked!');});

But the the function above occurs before the default function of 'Zoom To'. I wouldn't mind their click function executing, so long as it fires after mine does.

Any ideas?

Best Answer

You can disconnect the ESRI Zoom To function like this:

dojo.disconnect(map.infoWindow._eventConnections[4]);

This assume your var map = esri.Map(). The the fifth element in the _eventConnections array is the zoom to event.

Then you can attach your own events to the Zoom To with jQuery or dojo:

// Add custom zoom To
$('.action.zoomTo').click(function () { alert('First!'); });
$('.action.zoomTo').click(function () { alert('Second!'); });

It appears that the new connection can only be made after the an InfoTemplate is instantiated.