FeatureLayer click event handler event object not as expected.

6184
5
11-28-2013 08:46 AM
YvesRichard
New Contributor
I am binding a simple click handler to a FeatureLayer using the new 'on' strategy. All works fine in all browser except latest Firefox (25.0.1). The event object returned to the handler only has the ClientX & ClientY properties. To make things even more confusing looking at the esri docs here: https://developers.arcgis.com/en/javascript/jsapi/featurelayer-amd.html#click says that the handler should not expect a event object which contradicts the docs for the connect style handlers: https://developers.arcgis.com/en/javascript/jsapi/featurelayer-amd.html#onclick

1. how can i get around the Firefox issue?
2. Can you explain this discrepancy in the docs?

Regards, Yves

p.s. using esri js sdk ver 3.7

[ATTACH=CONFIG]29446[/ATTACH]
0 Kudos
5 Replies
JasonZou
Occasional Contributor III
One thing I would try is to

Change:
on(layer, "click", function(evt) {})

To:
layer.on("click", function(evt) {});

Based om dojo/on document, on(layer, "click", ...) is applied to dom elements, which means it considers layer as a dom element instead of an esri/layers/FeatureLayer. Use layer.on("click", ...) to define the callback function for FeatureLayer.onClick event.
0 Kudos
YvesRichard
New Contributor
Tried you solution but no luck still getting the same result.

[ATTACH=CONFIG]29452[/ATTACH]

Any other ideas?
0 Kudos
JohnGravois
Frequent Contributor
Yves,
in this sample, we dig into the returned object for the graphic associated with the click event using 'e.graphic'.  you're unable to do the same?

heres a conceptual article that details the differences between the objects returned by on style event listeners and connect style event listeners
https://developers.arcgis.com/en/javascript/jshelp/inside_events.html
0 Kudos
YvesRichard
New Contributor
haha my bad!

I was just hovering over the evt variable which only showed the clientX & clientY values and I thought that those where the only properties on the object but on closer inspection all the esri properties are present.

On my second note about the docs though... shouldn't the click handler be served a mouse event? In the docs it says it doesn't receive one. (see attached image)

Thank you for your time.

[ATTACH=CONFIG]29498[/ATTACH]
0 Kudos
JohnGravois
Frequent Contributor
yeah, we'll have to correct the doc for the on style click event.
0 Kudos