Thanks Ken, that wasn't exactly what I was trying to do but taking another look at the IdentifyTask example helped me to get where I needed to go. I actually have two feature layers that I want to get results from (Segments and Intersections). I was able to used the deferred.addCallback and the dojo.map methods from the IdentifyTask example to combine the results and get the content into the popup. In case anyone is interested, here is what I came up with...
dojo.connect(map, "onClick", function (evt) {
var query = new esri.tasks.Query();
//Query within 20 pixels of click point
query.geometry = pointToExtent(map, evt.mapPoint, 20);
//I have two feature layers with setDefinitionExpression applied (intersections, segments)
var deferred = featureLayerSeg.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
deferred.addCallback(function (responseSeg) {
var response;
var deferInt = featureLayerInt.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
deferInt.addCallback(function (responseInt) {
//Concatenate the arrays of selected features from the two feature layers
response = responseSeg.concat(responseInt);
});
return dojo.map(response, function (result) {
var content = getPopupContent();
var template = new esri.InfoTemplate("", content);
result.setInfoTemplate(template);
return result;
});
});
popup.setFeatures([deferred]);
popup.show(evt.mapPoint);
});
function getPopupContent() {
var viewPermitLink = "<a href=\"javascript:ExecuteViewPermit('${PermitNumber}');\">View Details</a>";
var streetViewLink = "<a href=\"javascript:showMapInDialog('${PermitNumber}');\">Street View</a>";
var content = "<b>Permit Number</b>: ${PermitNumber}" + "<br><b>On Street</b>: ${OnStreetName}" + "<br><b>From Street</b>: ${FromStreetName}" + "<br><b>To Street</b>: ${ToStreetName}" + "<br>" + viewPermitLink + " " + streetViewLink;
return content;
}