Hi All,
I have been following this sample: Geoprocessing tool link in popup | ArcGIS API for JavaScript
The problem I'm having is that it applies to every feature layer on the map where I've set an infoTemplate and I only want the the extra functionality for one of the layers. I've been trying to set the content for the infoTemplate and add the link in the setContent function but it's not working. It prevents the attribute values from displaying and also doesn't doesn't show the link. I'm puzzled by it because I am able to create a ContentPane. Why is constructing an anchor any different? I'm not sure how to solve this problem.
Here is some of my code:
// infoTemplate for Pour Points
var wbd10PourPointsInfoTemplate = new InfoTemplate({
title: "<strong>${CWUAS_NAME}</strong>",
});
wbd10PourPointsInfoTemplate.setContent(getWbd10PourPointInfoTemplateContent);
function getWbd10PourPointInfoTemplateContent(graphic) {
var content = "<strong>HUC10</strong>: " + graphic.attributes.HUC_10 + " </br>" +
"<strong>Square Miles</strong>: " + graphic.attributes.SQM + " </br>" +
"<strong>Type</strong>: " + graphic.attributes.PRPT_TYPE + " </br>" ;
// Make a tab container.
var cp = new ContentPane({
content: content
}, domConstruct.create("div"));
// THIS IS THE SECTION OF CODE THAT PREVENTS ANY VALUES FROM DISPLAYING IN THE CONTENT. IF THIS IS COMMENTED OUT THEN ALL OF THE ATTRIBUTE VALUES DISPLAY. IF I MOVER IT OUT OF THIS BLOCK THEN ALL OF THE VALUES DISPLAY AND I ALSO GET THE FUNCTIONAL LINK, BUT THEN IT ALSO SHOWS ON INFO TEMPLATES WHERE I DO NOT WANT TO DISPLAY THE LINK
var link = domConstruct.create("a", {
"class": "action",
"id": "statsLink",
"innerHTML": "Display Watershed", //text that appears in the popup for the link
"href": "javascript: void(0);"
}, query(".actionList", window.map.infoWindow.domNode)[0]);
on(link, "click", displayWatershed);
return cp.domNode;
}
I handled this issue by simply hiding and displaying the link in the feature layer click event. If the feature layer where I want to display the link is clicked then I show it. For all other feature layer clicks I hide it. This way i can run with the code provided in the sample that adds it at the top level.
Code Example:
myFeatureLayer.on("click", function (evt) {
// show the link
$("#statsLink").show()
});
otherFeatureLayer.on("click", function (evt) {
// hide the anchor
$("#statsLink").hide();
});
Has anyone else found a way to achieve this. I would like my link to only appear for one feature. Is there a way to hide the link in all features and only expose it to one? I am working in the PopupManager.js ....
M E,
Since you mention PopupManager.js that means you are talking about WAB so you should start a new question in the WAB space or the Custom Widgets group.