I would second Steve's suggestion about tying the popup to a feature layer. For example, in one of my maps, I define the popup content at the beginning of my initMap() function like this: var removalTemplate = new esri.InfoTemplate();
removalTemplate.setContent('<table cellspacing=\"5\" style=\"font-size:90%\"><tr><td style=\"vertical-align:top\"><b>Road Name:</b></td><td style=\"vertical-align:top\">${Name}</td></tr><tr><td style=\"vertical-align:top\"><b>Snow Removal Priority:</b></td><td style=\"vertical-align:top\">${Priority:formatPriorityLabel}</td></tr></table>');
removalTemplate.setTitle('${Name}');
Next, you specify the template when you create the feature layer: // Define the Snow Removal Route layer
theSnowRemovalLayer = new esri.layers.FeatureLayer("URL to feature layer", {
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
infoTemplate:removalTemplate,
outFields: ["*"],
opacity:0.80,
visible: false
});
Towards the end, but still within the initMap() function, I associate the popup with the specific feature layer: dojo.connect(theSnowRemovalLayer,"onClick",function(evt){
//Listener event for feature selection and the popup info widow
var query = new esri.tasks.Query();
query.geometry = pointToExtent(map,evt.mapPoint,15);
var deferred = theSnowRemovalLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);
map.infoWindow.resize(map.width * 0.55,map.height * 0.25);
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(evt.mapPoint);
});
Hopefully that makes sense. Good luck!Steve