I sorta found a solution. It is a bit convoluted and involved overriding the response.clickEventHandle of the AGOL webmap.I created global var that includes popup info from AGOL.
//added global var to handle TOC popups
if (configOptions.custPopup === "TOC") {
operationalLayers = response.itemInfo.itemData.operationalLayers;
dojo.forEach(operationalLayers, function(layer) {
dojo.forEach(layer.layers, function(sublayer) {
dojo.forEach(sublayer.popupInfo.fieldInfos, function(fieldInfo) {
//move alias values into fieldname so it will work as fieldInfo
fieldInfo.fieldName = fieldInfo.label;
});
});
});
}
Then i added function to execute ID task using the AGOL popups.function executeTOCIdentifyTask(evt) {
//set the visible layers for the ID
var layers = [];
dojo.forEach(toc.layerInfos[0].layer._tocInfos, function(layer) {
if (layer.visible) {
layers.push(layer.id);
}
});
if (layers.length > 0) {
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
identifyParams.tolerance = 9;
identifyParams.returnGeometry = true;
identifyParams.layerIds = layers;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParams.width = map.width;
identifyParams.height = map.height;
identifyParams.timeExtent = map.timeExtent;
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function(response) {
return dojo.map(response, function(result) {
var feature = result.feature;
var template;
dojo.forEach(operationalLayers[0].layerObject.layerInfos, function(layer) {
//get the right layer from operationalLayers
if (result.layerName == layer.name) {
//get the right popup from operationalLayers
dojo.forEach(operationalLayers[0].layers, function(popup) {
if (popup.id == layer.id) {
template = new esri.dijit.PopupTemplate({
title: popup.popupInfo.title,
fieldInfos: popup.popupInfo.fieldInfos,
showAttachments : popup.popupInfo.showAttachments
});
}
});
}
});
feature.setInfoTemplate(template);
return feature;
});
});
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(evt.mapPoint);
}
}