map infoWindow shows correctly, graphic infoWindow is blank

1153
6
06-14-2013 09:54 AM
LukePhilips
New Contributor III
Upon clicking on a map feature (onClick -> Feature select -> onSelection -> go build an infoWindow)

after building my infoWindow and creating a graphic I want to show the infoWindow:

var graphic = new esri.Graphic;
graphic.setGeometry(feature.geometry);
graphic.setAttributes(feature.attributes);
graphic.setSymbol(mySymbol); 

var template = new esri.InfoTemplate();
template.setTitle('MyTitle');
template.setContent(bc.domNode); //dijit BorderContainer

graphic.setInfoTemplate(template);

map.graphics.add(graphic);
map.infoWindow.setContent(template.content);
map.infoWindow.setTitle(template.title);
map.infoWindow.show(graphic.geometry, map.getInfoWindowAnchor(graphic.geometry));


I get the immediate infoWindow to show, the graphic draws fine. Subsequent clicks on the same point shows a blank infoWindow, it only shows data again when I click away then click back on the point to restart the selection process.
0 Kudos
6 Replies
JonathanUihlein
Esri Regular Contributor
I do something similar in one of my projects.

However, I end up assigning events to "onSelectionChange", "onSetFeatures" and "onClearFeatures" and populate the infoWindow accordingly, depending on the situation.

This sample may or may not help (even if its not exactly what you are doing):
http://developers.arcgis.com/en/javascript/jssamples/popup_sidepanel.html
0 Kudos
LukePhilips
New Contributor III
Jon,
Thanks for the response. However, those aren't the issue. I have already selected the feature, I'm not changing the feature (not clicking another feature), nor clearing features, simply clicking the same feature after the infoWindow has already popped up. At that point the infoWindow goes from populated data to blank.
0 Kudos
BrittneyGibbons
New Contributor III
Is it possible that the node used to generate the content for your infoWindow is getting destroyed between the first and second clicks? I had something similar happen to me when I closed the infoWindow and ended up having to clone the node for the infoWindow rather than assign it directly.
0 Kudos
JonathanUihlein
Esri Regular Contributor
Jon,
Thanks for the response. However, those aren't the issue. I have already selected the feature, I'm not changing the feature (not clicking another feature), nor clearing features, simply clicking the same feature after the infoWindow has already popped up. At that point the infoWindow goes from populated data to blank.


Sorry Luke! Looks like I misunderstood.

I was under the assumption that clicking an already-selected feature causes the feature to become unselected (meaning your infowindow would go blank since there's no feature selected). This is why I used onSelectionChange instead of onSelection.
0 Kudos
RahulGupta1
New Contributor
you should assign infoTemplate for graphics layer also like this ...

var  template = new esri.InfoTemplate();
template.setTitle("<b>Layer</b>");
template.setContent(getWindowContentl);

function getWindowContentParcel(graphic) {
}

map.graphics.infoTemplate=template;



this will work.
0 Kudos
LukePhilips
New Contributor III
Is it possible that the node used to generate the content for your infoWindow is getting destroyed between the first and second clicks? I had something similar happen to me when I closed the infoWindow and ended up having to clone the node for the infoWindow rather than assign it directly.


Brittney, I think you are on the right track, though I'm not sure the best means of resolving the issue. On the first click (feature - onSelectionComplete) I can see the infoWindow with both .title and .content populated. However, on the subsequent click on the already selected feature, the .title stays the same, but the .content almost becomes empty - the main div remains (a BorderContainer), however the contents of the div are now empty (no more content pane's, etc..).
0 Kudos